[GHC] #9564: Floating point subnormals overrounded on output
GHC
ghc-devs at haskell.org
Sun Sep 7 10:46:08 UTC 2014
#9564: Floating point subnormals overrounded on output
-------------------------------------+-------------------------------------
Reporter: jrp | Owner: simonmar
Type: bug | Status: new
Priority: normal | Milestone:
Component: Runtime System | Version: 7.8.3
Keywords: | Operating System: MacOS X
Architecture: x86_64 (amd64) | Type of failure: Incorrect
Difficulty: Unknown | result at runtime
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
The following test suggests that GHC is overrounding Float subnormals,
when printing them out
{{{
Prelude> 2**(-149)
1.401298464324817e-45
Prelude> 2**(-149) :: Float
1.0e-45
Prelude> isDenormalized it
True
Prelude>
Prelude> 2**(-149) * 2**(100) * 2**(49) :: Float
1.0
}}}
By comparison
{{{
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
float clang_dec, clang_hex, libc_dec, libc_hex;
clang_dec = 1.401298464324817e-45;
clang_hex = 0x0.000002P-126;
printf("clang (from decimal) = %a\n",clang_dec);
printf("clang (from decimal) = %g\n",clang_dec);
printf("clang (from hex) = %a\n",clang_hex);
printf("clang (from hex) = %g\n",clang_hex);
libc_dec = strtod("1.401298464324817e-45",NULL);
libc_hex = strtod("0x0.000002P-126",NULL);
printf("libc (from decimal) = %a\n",libc_dec);
printf("libc (from decimal) = %g\n",libc_dec);
printf("libc (from hex) = %a\n",libc_hex);
printf("libc (from hex) = %g\n",libc_hex);
}
}}}
produces
{{{
clang (from decimal) = 0x1p-149
clang (from decimal) = 1.4013e-45
clang (from hex) = 0x1p-149
clang (from hex) = 1.4013e-45
libc (from decimal) = 0x1p-149
libc (from decimal) = 1.4013e-45
libc (from hex) = 0x1p-149
libc (from hex) = 1.4013e-45
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9564>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list