Precision for equality of two floats?

gene tani gene.tani at gmail.com
Tue Nov 29 16:41:33 CET 2005


Anton81 wrote:
> Hi!
>
> When I do simple calculation with float values, they are rarely exactly
> equal even if they should be. What is the threshold and how can I change
> it?
>
> e.g. "if f1==f2:" will always mean "if abs(f1-f2)<1e-6:"
>
> Anton

googled for "floating point" "comparison tolerance"
http://www.boost.org/libs/test/doc/components/test_tools/floating_point_comparison.html




More information about the Python-list mailing list