The stupid question is the question not asked | |
PerlMonks |
Re: When 1000 is less than 1000by sundialsvc4 (Abbot) |
on Sep 27, 2010 at 14:21 UTC ( [id://862222]=note: print w/replies, xml ) | Need Help?? |
Even though the computer displays “sensible” decimal numbers to you, with so-many decimals and so forth, it actually works with base-two floating point numbers, whose internal values are almost never exactly equal to what you see. Thus, two values which “appear” to be exactly the same, probably aren’t. When comparing things, or when adding-up very long columns of figures, this makes all the difference. Therefore, you must round the numbers, or truncate them to integers or what-have-you, in order to produce the results you expect. This statement is true for all programming languages, spreadsheets, and so forth. P.S.: You will need to master the ability to explain these things, very patiently, to your friendly neighborhood accountant (or CFO). These are people who will cheerfully spend a hundred dollars looking for one penny, and who will make your life utterly miserable while doing it.
In Section
Seekers of Perl Wisdom
|
|