www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - std.math.frexp wrong on ARM

reply Johannes Pfau <nospam example.com> writes:
The frexp test fails on ARM. I think the mask in line 1491 is
wrong:

https://github.com/D-Programming-Language/phobos/blob/master/std/math.d#L1491
For doubles, the 63 bit is sign, 62-52 are exponent and 51-0 are
mantissa.
The mask manipulates the bits 63-48 (ushort, 16bit)
0x8000 is 0b1000000000000000
so it preserves the sign, but not the 4 bits of the mantissa? I think
it should be 
0b1000000000001111 (0x800F)?
This also fixes the test case on ARM.

But I don't know much about this stuff, so I wonder if this is correct?

(BTW: Shouldn't we use the binary representation for bitmasks instead?)
Sep 26 2012
next sibling parent Don Clugston <dac nospam.com> writes:
On 26/09/12 17:13, Johannes Pfau wrote:
 The frexp test fails on ARM. I think the mask in line 1491 is
 wrong:

 https://github.com/D-Programming-Language/phobos/blob/master/std/math.d#L1491
 For doubles, the 63 bit is sign, 62-52 are exponent and 51-0 are
 mantissa.
 The mask manipulates the bits 63-48 (ushort, 16bit)
 0x8000 is 0b1000000000000000
 so it preserves the sign, but not the 4 bits of the mantissa? I think
 it should be
 0b1000000000001111 (0x800F)?
 This also fixes the test case on ARM.

 But I don't know much about this stuff, so I wonder if this is correct?

You are correct. I will fix. At least, it's good that the tests caught that.
Sep 26 2012
prev sibling parent Johannes Pfau <nospam example.com> writes:
Am Wed, 26 Sep 2012 17:35:18 +0200
schrieb Don Clugston <dac nospam.com>:

 On 26/09/12 17:13, Johannes Pfau wrote:
 The frexp test fails on ARM. I think the mask in line 1491 is
 wrong:

 https://github.com/D-Programming-Language/phobos/blob/master/std/math.d#L1491
 For doubles, the 63 bit is sign, 62-52 are exponent and 51-0 are
 mantissa.
 The mask manipulates the bits 63-48 (ushort, 16bit)
 0x8000 is 0b1000000000000000
 so it preserves the sign, but not the 4 bits of the mantissa? I
 think it should be
 0b1000000000001111 (0x800F)?
 This also fixes the test case on ARM.

 But I don't know much about this stuff, so I wonder if this is
 correct?

You are correct. I will fix. At least, it's good that the tests caught that.

OK, thanks. Maybe we could also enhance the tests to test NaN, -NaN, +infinity, -infinity, +0,-0 and probably a denormal?
Sep 27 2012