|Subject:||hexfp may lose 1-3 low order bits (most often, 1)|
5.22.0, or bleadperl at 0c8adad7: $ ./perl -wle 'print 0xf.ffffffffffffp0' 16 $ ./perl -wle 'print 0xf.ffffffffffff8p0' Hexadecimal float: mantissa overflow at -e line 1. 16 $ ./perl -wle 'print 0xf.ffffffffffffcp0' Hexadecimal float: mantissa overflow at -e line 1. 16 The thing is, the second one is not an overflow: in the usual 53-bits-mantissa of IEEE doubles, that's exactly 53 bits. The third one has 54, so it correctly is an overflow. The first one is 52 bits, so not an overflow. I noticed this case while staring for at the code for perl #126582. So the last hexdigit with bits straddling the NV_MANT_DIG (often 53, see above), may or may not lose some of its bits. Note that this may be argued at least two ways: (1) if one specifies, say, 0x8, as the last hex digit, one may argue that one still specifies all the four bits, not just the top one. (2) or one may argue that one only specified the top bit. The code has so far been choosing the interpretation (1), but maybe the (2) makes more sense, because otherwise one may never specify all the 53 bits using the hexdigits, which is unfair the the very common case. (One could only specify up to 52 bits, using 13 hexdigits.) And hexfp is all about being able to specify the fp down to the last bit.