+ 7
1.1+0.1=1.2000000000000002???
why do 1.1 + 0.1=1.2000000000000002 ? in Julia language
7 Respostas
+ 17
The short answer is, that floating point arithmetic sucks. It's not only Julia, try and run
print(1.1+0.1==1.2)
in Python or try it in any other language.For the long answer, read https://en.m.wikipedia.org/wiki/Floating-point_arithmetic
+ 5
My pleasure. :)
+ 4
thanks alot
+ 4
You can either use the built in type Rational or get a package for decimal floating point arithmetic.
Both have their own limitations though.
+ 2
how can I avoid the error in my calculations?
+ 2
thanks
+ 1
high precision. Gotta tell it to convert to different type of different Float bit