std.math unittests - accuracy of floating point results
Dan Olson via digitalmars-d-ldc
digitalmars-d-ldc at puremagic.com
Sun Mar 1 20:19:29 PST 2015
"Johan Engelen" <j at j.nl> writes:
> Hi all,
> I am working on making more of the std.math unittests pass (I'm new
> to the project, and it is a nice niche thing to tinker on, learning
> the codebase, workflow, etc.).
> I've hit on a problem that I do not know how to handle: floating point
> comparison.
Hi Johan. I think you are running into similar problems I ran into with
64-bit reals on ARM. Hopefully there is a common solution for all
64-bit real architectures.
>
> (Incidentally, an inaccuracy of 1 ulp also haunts a std.csv unittest,
> but I do not yet know why exactly)
I encountered this too. I found that std.conv.parse!double with 64-bit
real is often off by 1 ulp compared to strod(). For 80-bit reals, they
match. I think the fix for this problem is a change to std.conv.parse.
> How should I go about fixing these unittests for us?
You could look in https://github.com/smolt/phobos/blob/ios/std/math.d
and see if any changes I made for iOS may help you. I have all
remaining problems marked with D versions that are prefixed with "WIP_",
like WIP_FloatPrecIssue.
Here are the phobos files possibly of interest:
std/csv.d
std/internal/math/errorfunction.d
std/internal/math/gammafunction.d
std/math.d
Hope this helps,
Dan
More information about the digitalmars-d-ldc
mailing list