15 # Test hexfloat literals.
41 is(0x0.100p0, 0.0625);
65 is(0x12p23, 0x12 << 23);
68 is(0x1p-2, 1 / (1 << 2));
69 is(0x1p-3, 1 / (1 << 3));
70 is(0x3p-4, 3 / (1 << 4));
71 is(0x3p-5, 3 / (1 << 5));
72 is(0x12p-23, 0x12 / (1 << 23));
87 # Hexdigits (lowercase).
94 is(0xab.cdp+0, 171.80078125);
96 # Uppercase hexdigits and exponent prefix.
100 is(0xAB.CDP+0, 171.80078125);
103 is(0xa_b.c_dp+1_2, 703696);
105 # Note that the hexfloat representation is not unique since the
106 # exponent can be shifted, and the hexdigits with it: this is no
107 # different from 3e4 cf 30e3 cf 30000. The shifting of the hexdigits
108 # makes it look stranger, though: 0xap1 == 0x5p2.
110 # Needs to use within() instead of is() because of long doubles.
111 within(0x1.99999999999ap-4, 0.1, 1e-9);
112 within(0x3.333333333333p-5, 0.1, 1e-9);
113 within(0xc.cccccccccccdp-7, 0.1, 1e-9);
117 local $SIG{__WARN__} = sub { $warn = shift };
125 { # Test certain things that are not hexfloats and should stay that way.
127 like(get_warn(), qr/Missing operator before p3/);
130 like(get_warn(), qr/Missing operator before p3/);
136 eval '$a = eval "0x.3"';
139 eval '$a = eval "0xc.3"';
146 if ($Config{nv_preserves_uv_bits} == 53) {
149 eval '0x1_0000_0000_0000_0p0';
150 is(get_warn(), undef);
152 eval '0x2_0000_0000_0000_0p0';
153 like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
155 eval '0x1.0000_0000_0000_0p0';
156 is(get_warn(), undef);
158 eval '0x2.0000_0000_0000_0p0';
159 like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
162 is(get_warn(), undef);
165 like(get_warn(), qr/^Hexadecimal float: exponent underflow/);
167 eval '0x1.fffffffffffffp+1023';
168 is(get_warn(), undef);
170 eval '0x1.fffffffffffffp+1024';
171 like(get_warn(), qr/^Hexadecimal float: exponent overflow/);
173 print "# skipping warning tests\n";
174 skip "nv_preserves_uv_bits is $Config{nv_preserves_uv_bits} not 53", 8;
178 # sprintf %a/%A testing is done in sprintf2.t,
179 # trickier than necessary because of long doubles,
180 # and because looseness of the spec.