Unittest tester.
Johannes Pfau
nospam at example.com
Mon May 20 01:25:38 PDT 2013
Am Tue, 14 May 2013 18:59:14 +0200
schrieb "Iain Buclaw" <ibuclaw at ubuntu.com>:
> core.exception.AssertError at libphobos/src/std/conv.d(2524):
http://dpaste.dzfl.pl/f995a4f3
Caused by a subtle difference when parsing floating point values in
the compiler. ldc produces the same result as gdc.
The asm generated for loading the 1.23456E+2 constant value is:
dmd:
--------
fldt 0x806f5dc #0x400ff120000000000000
fstpt -0x18(%ebp)
movw $0x0,-0xe(%ebp)
fldt 0x806f5e8 #0x4005f6e978d4fdf3b645
--------
gdc:
--------
movabs $0xf6e978d4fdf3b646,%rcx
mov $0x4005,%ebx #0x4005f6e978d4fdf3b646
--------
I think rounding at compile time could be the issue. The 1.23456E+2
value cannot be represented exactly with 80bit reals. If I calculate
the mantissa manually I get the ...45 if I simply disregard the part of
the mantissa which is > 63 bit. If I round after the 63. bit I get
the ..46 result.
So the question is: Is the rounding mode which should be used when
parsing a floating point literal specified?
I guess not. Then we could simply use a value in the test which fits
completely into the mantissa, like 123.375 (I wonder whether .456 was
used cause it fills all bits in the mantissa or whether that was by
accident...)
More information about the D.gnu
mailing list