use Config;
-plan(tests => 79);
+plan(tests => 85);
# Test hexfloat literals.
eval '0x1.fffffffffffffp+1024';
like(get_warn(), qr/^Hexadecimal float: exponent overflow/);
+
+ undef $a;
+ eval '$a = 0x111.0000000000000p+0'; # 12 zeros.
+ like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
+ is($a, 273);
+
+ # The 13 zeros would be enough to push the hi-order digits
+ # off the high-end.
+
+ undef $a;
+ eval '$a = 0x111.0000000000000p+0'; # 13 zeros.
+ like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
+ is($a, 273);
+
+ undef $a;
+ eval '$a = 0x111.00000000000000p+0'; # 14 zeros.
+ like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
+ is($a, 273);
} else {
print "# skipping warning tests\n";
- skip "nv_preserves_uv_bits is $Config{nv_preserves_uv_bits} not 53", 8;
+ skip "nv_preserves_uv_bits is $Config{nv_preserves_uv_bits} not 53", 14;
}
}
#ifdef HEXFP_NV
NV mult = 1 / 16.0;
#endif
- h++;
- while (isXDIGIT(*h) || *h == '_') {
+ for (h++; (isXDIGIT(*h) || *h == '_'); h++) {
if (isXDIGIT(*h)) {
U8 b = XDIGIT_VALUE(*h);
total_bits += shift;
+ if (total_bits < NV_MANT_DIG) {
#ifdef HEXFP_UQUAD
- hexfp_uquad <<= shift;
- hexfp_uquad |= b;
- hexfp_frac_bits += shift;
+ hexfp_uquad <<= shift;
+ hexfp_uquad |= b;
+ hexfp_frac_bits += shift;
#else /* HEXFP_NV */
- hexfp_nv += b * mult;
- mult /= 16.0;
+ hexfp_nv += b * mult;
+ mult /= 16.0;
#endif
+ }
}
- h++;
}
}