---- equals: x = 0.523599 equals: y = 0.523599 equals: ndigits = 16 bufx = '0.5235987755982989' bufy = '0.5235987755982988' core.exception.AssertError@runnable/testmath.d(134): Assertion failure ---- Seems the floating point calculations (or fp to string conversion) on ARM (or at least on the Raspberry Pi) are not precise enough to pass the tests in testmath.d. What should be done about this? 1. Lower required precision for all platforms 2. Special case ARM to lower precision 3. ?
What is this test supposed to do? ---- int exp; real mantissa = frexp(123.456, exp); assert(equals(mantissa * pow(2.0L, cast(real)exp), 123.456, 19)); ---- equals: x = 67.456 equals: y = 123.456 equals: ndigits = 19 bufx = '67.45600000000000307' bufy = '123.4560000000000031' core.exception.AssertError@testmath.d(170): Assertion failure
An alternate option could be to rethink the codegen for floating comparisons in GDC overall, as certain floating point comparisons fail in GDC x86/x86_64 too. Problem: Simply doing (A == B) is not correct. Possible solution: The comparison with an epsilon value is what most tends to be done in game programming. However the following: (diff = A - B, (diff < EPSILON) && (-diff > EPSILON))) Is a bit of wasted processing for something that should be fast, yet effective. Here's an interesting read-up: http://realtimecollisiondetection.net/blog/?p=89 Regards Iain
Not sure if we should do anything about this in the compiler. I wonder what dmd does? Anyway: https://github.com/D-Programming-Language/dmd/pull/1146 http://forum.dlang.org/thread/k3v614$2882$1@digitalmars.com hopefully fixed soon in upstream
Cool beans. By the way, if there's anything you need downstreaming to gdc, just send it my way. Thanks.
@Iain sure, I'll do that. But most of those fixes are just errors in the test suite, not really errors in the library/compiler, so that stuff can wait till the 2.061 merge. testmath.d has been removed from the test suite in upstream dmd (2.061), so I'm closing this. I hope Don won't forget the fix for frexp though. https://github.com/D-Programming-Language/dmd/commit/77ad29c6b38897881e849d6f80165921febe1293