14 # Test hexfloat literals.
40 is(0x0.100p0, 0.0625);
64 is(0x12p23, 0x12 << 23);
67 is(0x1p-2, 1 / (1 << 2));
68 is(0x1p-3, 1 / (1 << 3));
69 is(0x3p-4, 3 / (1 << 4));
70 is(0x3p-5, 3 / (1 << 5));
71 is(0x12p-23, 0x12 / (1 << 23));
86 # Hexdigits (lowercase).
93 is(0xab.cdp+0, 171.80078125);
95 # Uppercase hexdigits and exponent prefix.
99 is(0xAB.CDP+0, 171.80078125);
102 is(0xa_b.c_dp+1_2, 703696);
104 # Note that the hexfloat representation is not unique since the
105 # exponent can be shifted, and the hexdigits with it: this is no
106 # different from 3e4 cf 30e3 cf 30000. The shifting of the hexdigits
107 # makes it look stranger, though: 0xap1 == 0x5p2.
109 # Needs to use within() instead of is() because of long doubles.
110 within(0x1.99999999999ap-4, 0.1, 1e-9);
111 within(0x3.333333333333p-5, 0.1, 1e-9);
112 within(0xc.cccccccccccdp-7, 0.1, 1e-9);
116 local $SIG{__WARN__} = sub { $warn = shift };
124 { # Test certain things that are not hexfloats and should stay that way.
126 like(get_warn(), qr/Missing operator before p3/);
129 like(get_warn(), qr/Missing operator before p3/);
135 eval '$a = eval "0x.3"';
138 eval '$a = eval "0xc.3"';
145 if ($Config{nv_preserves_uv_bits} == 53) {
148 eval '0x1_0000_0000_0000_0p0';
149 is(get_warn(), undef);
151 eval '0x2_0000_0000_0000_0p0';
152 like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
154 eval '0x1.0000_0000_0000_0p0';
155 is(get_warn(), undef);
157 eval '0x2.0000_0000_0000_0p0';
158 like(get_warn(), qr/^Hexadecimal float: mantissa overflow/);
161 is(get_warn(), undef);
164 like(get_warn(), qr/^Hexadecimal float: exponent underflow/);
166 eval '0x1.fffffffffffffp+1023';
167 is(get_warn(), undef);
169 eval '0x1.fffffffffffffp+1024';
170 like(get_warn(), qr/^Hexadecimal float: exponent overflow/);
172 print "# skipping warning tests\n";
173 skip "nv_preserves_uv_bits is $Config{nv_preserves_uv_bits} not 53", 8;
177 # sprintf %a/%A testing is done in sprintf2.t,
178 # trickier than necessary because of long doubles,
179 # and because looseness of the spec.