Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Multiplication problem

by oha (Friar)
on Dec 10, 2007 at 16:51 UTC ( #656175=note: print w/replies, xml ) Need Help??


in reply to Multiplication problem

why you don't simply use cents as the base units and when you print out data you just:
sub tostring { my $cent = "00". shift; $cent =~ s/(\d\d)$/.$1/; $cent =~ s/^0+(\d)/$1/; 1 while($cent =~ s/(\d)(\d\d\d[.'])/$1'$2/); $cent; } print tostring(2)." + ".tostring(99998)." = ".tostring(100000)."\n"; # => .02+999.98=1'000.00
Oha

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://656175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2022-01-19 02:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (55 votes). Check out past polls.

    Notices?