Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Multiplication problem

by oha (Friar)
on Dec 10, 2007 at 16:51 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found