diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2015-02-08 12:45:01 -0500 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2015-02-08 21:54:51 -0500 |
commit | 30419b527d2c5a06cefe2db9183f59e2697c47fc (patch) | |
tree | 15c65c264ee110d44c090ee386c480a38bcbb38c /sv.c | |
parent | 29b62199cd4c359dfc6b9d690341de40d105ca5f (diff) | |
download | perl-30419b527d2c5a06cefe2db9183f59e2697c47fc.tar.gz |
infnan: the nan quiet/signaling bit is not enough
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -3257,19 +3257,12 @@ S_infnan_2pv(NV nv, char* buffer, size_t maxlen, char format, char plus, char al *s++ = 'n'; *s++ = 'f'; } else if (Perl_isnan(nv)) { - U8 mask; - NV payload = nv; - U8* hibyte = nan_hibyte(&payload, &mask); *s++ = 'N'; *s++ = 'a'; *s++ = 'N'; if (nan_is_signaling(nv)) { *s++ = 's'; } - /* Detect and clear the "quiet bit" from the NV copy. - * This is done so that in *most* platforms the bit is - * skipped and not included in the hexadecimal result. */ - *hibyte &= ~mask; if (alt) { U8 vhex[VHEX_SIZE]; U8* vend; @@ -3279,10 +3272,13 @@ S_infnan_2pv(NV nv, char* buffer, size_t maxlen, char format, char plus, char al bool upper = isUPPER(format); const char* xdig = PL_hexdigit + (upper ? 16 : 0); char xhex = upper ? 'X' : 'x'; + U8 mask; + NV payload = nv; + U8* hibyte = nan_hibyte(&payload, &mask); - /* We need to clear the bits of the first - * byte that are not part of the payload. */ - *hibyte &= (1 << (7 - NV_MANT_REAL_DIG % 8)) - 1; + /* Clear the bits that are not part of the payload. */ + *hibyte &= ~mask; + *hibyte &= ((1 << (NV_NAN_BITS % 8)) - 1); vend = S_hextract(payload, &exponent, vhex, NULL); S_hextract(payload, &exponent, vhex, vend); |