darnocian 87 Posted March 30 14 minutes ago, David Heffernan said: It depends on what you are comparing, what algorithms are involved etc. Ok. I was just hoping for some sort of example, as the SameValue/isZero is a generalised approach. So back to the original post, I guess we can just take it that there are some issues with the new version of the compiler, and will need to log some issues with QP once it is back again. Share this post Link to post
David Heffernan 2350 Posted March 30 5 minutes ago, darnocian said: Ok. I was just hoping for some sort of example, as the SameValue/isZero is a generalised approach. So back to the original post, I guess we can just take it that there are some issues with the new version of the compiler, and will need to log some issues with QP once it is back again. Sometimes you do compare up to tolerance. Sometimes that's the right way to do it. But you need to know how to choose the tolerance. And it's definitely wrong to say that one must never compare exactly. Sometimes you can. Although delphi rtl works against you. For instance you'd hope to be able to convert floats to text, and back, and get the same value. In Delphi using the rtl functions this isn't always the case. Embarcadero have known this for more than a decade and not done anything yet. I just don't think they have the resources required to prioritise this given all their other commitments. 1 Share this post Link to post
Roger Cigol 104 Posted April 1 (edited) How about an example of how you have to pick your "epsilon" value with knowledge of what's going on: If I am working out shortest route to walk from London to Birmingham I might use floating point values to store route distance in km (roughly 175 km). I might consider any route that is within 1km of another route as being "equal" from the perspective of route assessment. So I can set a large epsilon when making my route comparisons. But if I am launching a module and trying to land it on a flat bit of the moon my route is roughly 400,000km but I want the landing point to be accurate to a couple of meters so I would need to choose a much tighter epsilon. David is right - offering a "hidden" arbitrary epsilon value that works for "most cases" is a route that is often convenient but it is a potentially dangerous approach. Floating point values are the right approach for many coding problems but they do need using with an understanding of how they work and the inherent "limitations" that result from how they work. Edited April 1 by Roger Cigol Share this post Link to post
Uwe Raabe 2060 Posted April 1 I have written a couple of applications for CNC machines. The majority are for wood working and those usually have a resolution of 0.001 mm. Therefore the Epsilon used for matching element start/end points is set to 0.0005. When calculating parallel contours there often are cases where very small elements appear that have to be removed and the disjunct neighbors need some trimming to an intersection. These cases need a much finer epsilon than the first one. Side note: Regression tests comparing float calculations created under Win32 can easily fail when executing on a Win64 platform. Share this post Link to post