[Israel.pm] perl arithmetic
migo at homemail.com
Sun Apr 18 09:04:06 PDT 2004
On 18 Apr 2004 18:05:32 +0300, Pinkhas Nisanov wrote:
> On Sun, 2004-04-18 at 17:51, Yuval Kogman wrote:
> > What I meant was always work with the highest percision you can, using
> > integer arithmetic, never converting to float, except for formatting
> > purposes.
> I do not convert it to float, I get it float from input.
> It's actually product price.
You do convert the input from string to float. Convert it to int instead.
my $price_string = "4.56";
die "Incorrect price\n" unless $price_string =~ /^(\d+)(?:\.(\d\d))$/;
my $price_agorot = $1 * 100 + ($2 || 0);
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'
More information about the Perl