|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: Simple addition/subtraction not workingby GrandFather (Cardinal) |
| on Dec 01, 2011 at 22:15 UTC ( #941182=note: print w/ replies, xml ) | Need Help?? |
|
If you are dealing with a budget work in cents and the issue will go away. The problem is that most decimal fractions can't be represented as finite binary fractions and computers tend to have finite representations for numbers. There are various other ways to deal with the problem depending on your application. But if you are dealing with money to the nearest cent then working in cents avoids the problem entirely because you are then working with integers which are exactly represented in binary or decimal.
True laziness is hard work
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||