Hi Damian —
Most of Chapel's math functions do simply wrap C's 'math.h' and 'libm'
(glibc or otherwise depending on what back-end compiler you're using I
suppose). The cbrt() function itself is just a pass-through to C's cbrt()
so it seems it should not behave differently.
According to the C program I just wrote up correctly, it looks like the
result should be:
0x1.0p-348
not:
0x1.0p-340
and using this value seems to work for me:
if cbrt(0x1.0p-1044) == 0x1.0p-348 then
writeln("Matches");
else
writeln("Doesn't match");
Try it online:
https://tio.run/##S85ILEjN@f8/M00hOamoRMOgwlDPoEDX0MDERFPB1lYByjc2sVAoyUjN41JQKC/KLEnNydNQ8k0sSc5ILVbStOZSSM0pTgXKISRd8lOL89RLFHJBioBK/v8HAA
All that said, I don't trust my eyesight very well these days, so may have
transcribed something incorrectly.
-Brad
On Tue, 5 Mar 2019, Damian McGuckin wrote:
Where does the Math library come from? I was thinking that it picks up GLIBC
but I am not sure.
Given the sub-normal IEEE 754 number 2^(-1044)
cbrt(0x1.0p-1044) = 0x1.0p-340 (exactly)
When I use my own cube root function which is done in a generic style, I get
an exact answer as does C/C++. but under Chapel it returns an answer with a
relative error of
0.5*epsilon
I was curious where I should be looking. If Chapel is just using whatever is
the latest version of the standard C library on a given machine, I will look
in my test program.
Also, there is no 'nextafter' routine in Chapel's math library, a.k.a.
man nextafter
but I can donate mine (done in Chapel) from my IEEE 754 project sometime
soon.
Thanks - Damian
Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers