[Issue 3751] Optimalization error in some floating point code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 29 05:50:48 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3751
--- Comment #7 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2010-01-29 05:50:47 PST ---
(In reply to comment #5)
>
> I think this is exactly the problem. You are using floating point expecting
> that all floats are created equal.
>
> One rule about floating point is never to build an infinite loop waiting for
> two floats to converge using ==. You must use an epsilon if you expect any
> reasonable result.
I know this.
>
> Your exit condition is this:
>
> if (left == half || right == half)
>
> What about trying this:
>
> if(half - left < SOME_EPSILON || right - half < SOME_EPSILON)
>
> where SOME_EPSILON is a very small insignificant number, like 0.000001
>
> floating point convergence is an art form, you need to understand its
> limitations.
Yes I know, but I was relaying of IEEE 754 semantic, in which my code should
work (there will be point in execuion when left == half or right == half
exactly!). I was just trying to write this routine to be slightly faster just
by not using EPSILONS and substractions.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list