Talk:Approximate equality: Difference between revisions

Insufficient test cases
m (Thundergnat moved page Talk:Approximate Equality to Talk:Approximate equality: Follow normal task title capitalization policy)
(Insufficient test cases)
Line 1:
==Insufficient test cases and incorrect implementations==
The test cases for this problem are insufficient to ensure that the solutions handle numbers differently at different scales in many common languages, even though the problem description says that they should. Specifically, using a 64-bit IEEE floating point number (which is the largest many languages offer, and some only offer even smaller floating point types), the test-case numbers 100000000000000.01 and 100000000000000.011, which the problem statement says should test whether larger numbers are allowed larger errors, are actually equal, with the representation 100000000000000.015625. At present, this oversight is exploited by many (if not most) of the implementations, which simply test whether the absolute difference of the inputs is less than 1e-18.
 
Specifically, the incorrect solutions are any which are based (directly or indirectly) on the C# solution, the Delphi solution (as its standard comparison function only uses an absolute difference), the FreeBasic solution, the Mathematica solution, the Scala solution, and the Wren solution. It seems that especially many of the more popular languages have incorrect solutions (as many are based on the C#, C, or Java solution).
 
I would like to change this test case to involve numbers a few binary orders of magnitude less (to give room for languages with slightly smaller floats) and perhaps also include a test-case for 32-bit and/or 16-bit floats, in order to force implementations in any language to allow for differences in magnitude, but the fact that this would invalidate many existing solutions may be an issue. Perhaps the existing solutions which operate only on an absolute difference between numbers could be moved to a different page? [[User:Goose121|Goose121]] ([[User talk:Goose121|talk]]) 00:04, 20 November 2021 (UTC)
 
==Can of worms==
Anonymous user