+ 6
int() issue
Why >>> 4.9 - int(4.9) == 0.9000000000000004 and not 4.9 - int(4.9) == 0.9 ..?
6 odpowiedzi
+ 11
https://docs.python.org/2/tutorial/floatingpoint.html
+ 10
When we deal with floating point arithmetic with high number of decimal values, equality shouldn't be used. You will want to compare your value with a range of acceptable values, and this can be done by introducing epsilons. That said, this isn't always the case. It depends on the nature of the issue you are dealing with.
https://stackoverflow.com/questions/2729637/does-epsilon-really-guarantees-anything-in-floating-point-computations
+ 7
@Hatsy: That book available on the link you provided seems it may be very informative.
Sigh.. Added to the reading list 😦
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
+ 6
Python isnt the best calculator.
For example. 1/3+2/3=1.0000000000000000001 not 1 has it does 0.333333333333+0.666666666667
+ 5
Is there anyway ti remove effect
+ 4
Oh I see.. thx