RE: RE: Floating point math is the devil!
You are viewing a single comment's thread from:

RE: Floating point math is the devil!

Words
49
Reading
1 min
5y

It gets even weirder!

I tried this in clojure...

(* 0.000001 125) => 1.25E-4

(* 0.0000001 125) => 1.2499999999999999E-5

This is the same as your result.

But then go one step further:

(* 0.00000001 125) => 1.25E-6

We are back to an accurate result!

But using the division operation instead of multiplication gives different accuracy:

(/ 125 10E7) => 1.25E-6

(/ 125 10E6) => 1.25E-5

Floating point arithmetic is hilarious!