Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Another exercise to represent fractions in binary is to take the decimal and multiply by two in a column.
Now taking the whole number and going from bottom to top you get 101, the binary representation, exactly. If you take .1 you get
And from that point you get a repeating sequence in binary similar to .333..3 in decimal And the takeaway is instead of testing for equality in floating point you test against an Epsilon (small quantity) and if the two numbers are within that Epsilon close to each other, they are for all intents are purposes, equal. Not doing so introduces bugs. In reply to Re: floating point addition
by trippledubs
|
|