Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: When 1000 is less than 1000

by sundialsvc4 (Abbot)
on Sep 27, 2010 at 14:21 UTC ( [id://862222]=note: print w/replies, xml ) Need Help??


in reply to When 1000 is less than 1000

“Floating-point numbers like little piles of sand on the ground.   Each time you pick one up and move it around, you lose a little sand and you pick up a little dirt.”

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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 11:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found