How can I *safely* get rid of fractions by multiplying by 100? I need to convert currency amounts this way and I'm out of ideas. I could do something like:my $amount = 35784.45; $amount *= 100; print $amount, "\n"; # gives 3578445 print int($amount); # gives 3578444 (!)
but isn't there any easier way?$amount =~ s/^(\d+)\.(\d{2})$/$1$2/
In reply to Strange int() result by menth0l
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |