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

Re^3: While loop with addition goes weird (binary float rounding error)

by BillKSmith (Prior)
on Apr 09, 2018 at 04:00 UTC ( #1212561=note: print w/replies, xml ) Need Help??


in reply to Re^2: While loop with addition goes weird (binary float rounding error)
in thread While loop with addition goes weird

We can almost always ignore floating-point errors and round our results with printf. Unfortunately there is no "simplistic" way to recognize the rare cases where this is a bad idea (Or what to do about it if you really have one). The documents already cited are not easy to read! Be assured that they to not require knowledge of any math beyond elementary algabra - only a commitment to learn.
Bill
  • Comment on Re^3: While loop with addition goes weird (binary float rounding error)

Replies are listed 'Best First'.
Re^4: While loop with addition goes weird (binary float rounding error)
by Anonymous Monk on Apr 13, 2018 at 19:50 UTC
      The OP probably has the same off-by-one error as your second reference. The floating-point accuracy issue clearly applies to the current question.
      Bill

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2020-10-22 07:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (225 votes). Check out past polls.

    Notices?