tolerance :o)
-
Hi, I have a function bool equal(double val) { if(val == 0.0) return true; else return false; } if val = 0.0; function will return true if val = 0.0000000000000001; function will return false Is there a way to set a tolerance so that 0.0 == 0.000000000000001 -> true? Thanks Everything's beautiful if you look at it long enough...
-
Hi, I have a function bool equal(double val) { if(val == 0.0) return true; else return false; } if val = 0.0; function will return true if val = 0.0000000000000001; function will return false Is there a way to set a tolerance so that 0.0 == 0.000000000000001 -> true? Thanks Everything's beautiful if you look at it long enough...
-
Hi, I have a function bool equal(double val) { if(val == 0.0) return true; else return false; } if val = 0.0; function will return true if val = 0.0000000000000001; function will return false Is there a way to set a tolerance so that 0.0 == 0.000000000000001 -> true? Thanks Everything's beautiful if you look at it long enough...
Hi, Look into the msdn article Why Floating-Point Numbers May Lose Precision there's a neat piece of code with an example equality comparison macro with support for tolerance.
-
Hi, Look into the msdn article Why Floating-Point Numbers May Lose Precision there's a neat piece of code with an example equality comparison macro with support for tolerance.
Thanks for the link. It looks like a good and efficient solution. John