Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Getting stranger values in subtraction

by hdb (Monsignor)
on Feb 06, 2016 at 08:13 UTC ( [id://1154550]=note: print w/replies, xml ) Need Help??


in reply to Getting stranger values in subtraction

Computers cannot be trusted with arithmetics...

Have a look at this thread or look for "floating point arithmetic" in Super Search.

  • Comment on Re: Getting stranger values in subtraction

Replies are listed 'Best First'.
Re^2: Getting stranger values in subtraction
by MidLifeXis (Monsignor) on Feb 08, 2016 at 13:55 UTC

    This might be a bit strong. Perhaps "Naive Programmers cannot be trusted to use computers to do arithmetic." :-)

    If you are aware of the limitations based on how the hardware, libraries, and language does arithmetic (iow - know your tools), computers can be used to do the job just fine. I had two courses in this in college that dealt with this topic - one in the math department and one in the CS department. It is a similar concept to students writing down a highly precise, but terribly inaccurate answer on a test because they didn't understand significant digits and error accumulation.

    --MidLifeXis

      Fully agree. In this context -3.5527136788005e-015 seems to be close enough to zero for any practical purpose.

      But this "naive" behavior can be seen so often not only with students but also in real applications for commercial purposes (which costs real money).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-23 14:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found