News for hackers. Stuff that matters.
Re:Floating point error is the least of my worries (2011) by ajross on Wednesday February 21, 2018 @08:49PM (#16434572)
That's only a place you would "never expect" because you've carefully hidden the gotcha. Stated less obtusely, you're finding the intersection between two lines which are parallel to JUST above the precision of an IEEE double. This is a cute example, not a real world situation. In the real world, precision loss in this circumstance is acceptable and any real system that accepted a "parallel" condition like this would have a check for it.

For a similar situation: atan2() exists because of a coverage issue in the problem area and not a bug in the idea of a tangent or a float.

Re:Floating point error is the least of my worries (2011) by ajkjk on Wednesday February 21, 2018 @09:07PM (#16434647)
I would think that atan2() exists because atan() doesn't invert tan() correctly for some purposes -- if you're trying to find the angle associated with a point then atan(y/x) is just the wrong answer.

The fact that it avoids the division by 0 is a convenient side effect of also being more correct.

(I'm just guessing; I don't know the actual history of it.)

Re:Floating point error is the least of my worries (2011) by ajross on Thursday February 22, 2018 @01:48AM (#16435709)
The point was more that problems that need to use atan() in a context where the line may point near the Y axis don't flip out over "floating point precision", they just use atan2().

Problems like the one in the grandparent that need to intersect nearly-parallel lines (or subspaces) use special techniques better suited to the problem and don't just feed it to a linear solver.

Re:Floating point error is the least of my worries (2011) by mehrdadn on Wednesday February 21, 2018 @09:33PM (#16434757)
How does that contradict what the parent was saying? Parent said problems like this can come up where you least expect it, and you rebutted that "this is not a real world situation" because "any real system that accepted a 'parallel' condition like this would have to check for it"? If anything you're confirming the point, not refuting it.
Re:Floating point error is the least of my worries (2011) by ajross on Thursday February 22, 2018 @01:10AM (#16435505)
This is a carefully constructed (malformed) problem presented in an obfuscated way. It didn't "just happen" that those ~20 bit numbers happen to produce slopes that differ only after ~57 bits, come on. If you're going to do that kind of trickery, you can come up with an equivalent that blows up any fixed precision limit and/or explodes the representation size for any arbitrary precision computation system.

It's a parlor trick, not a serious problem.