This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix more -IV_MIN negations
[perl5.git] / t / opbasic / arith.t
1 #!./perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6 }
7
8 # This file has been placed in t/opbasic to indicate that it should not use
9 # functions imported from t/test.pl or Test::More, as those programs/libraries
10 # use operators which are what is being tested in this file.
11
12 print "1..186\n";
13
14 sub try ($$$) {
15    print +($_[1] ? "ok" : "not ok"), " $_[0] - $_[2]\n";
16 }
17 sub tryeq ($$$$) {
18   if ($_[1] == $_[2]) {
19     print "ok $_[0]";
20   } else {
21     print "not ok $_[0] # $_[1] != $_[2]";
22   }
23   print " - $_[3]\n";
24 }
25 sub tryeq_sloppy ($$$$) {
26   if ($_[1] == $_[2]) {
27     print "ok $_[0]";
28   } else {
29     my $error = abs (($_[1] - $_[2]) / $_[1]);
30     if ($error < 1e-9) {
31       print "ok $_[0] # $_[1] is close to $_[2], \$^O eq $^O";
32     } else {
33       print "not ok $_[0] # $_[1] != $_[2]";
34     }
35   }
36   print " - $_[3]\n";
37 }
38
39 my $T = 1;
40 tryeq $T++,  13 %  4, 1, 'modulo: positive positive';
41 tryeq $T++, -13 %  4, 3, 'modulo: negative positive';
42 tryeq $T++,  13 % -4, -3, 'modulo: positive negative';
43 tryeq $T++, -13 % -4, -1, 'modulo: negative negative';
44
45 # Give abs() a good work-out before using it in anger
46 tryeq $T++, abs(0), 0, 'abs(): 0 0';
47 tryeq $T++, abs(1), 1, 'abs(): 1 1';
48 tryeq $T++, abs(-1), 1, 'abs(): -1 1';
49 tryeq $T++, abs(2147483647), 2147483647, 'abs(): 2**31-1: pos pos';
50 tryeq $T++, abs(-2147483647), 2147483647, 'abs(): 2**31-1: neg pos';
51 tryeq $T++, abs(4294967295), 4294967295, 'abs(): 2**32-1: pos pos';
52 tryeq $T++, abs(-4294967295), 4294967295, 'abs(): 2**32-1: neg pos';
53 tryeq $T++, abs(9223372036854775807), 9223372036854775807,
54     'abs(): 2**63-1: pos pos';
55 tryeq $T++, abs(-9223372036854775807), 9223372036854775807,
56     'abs(): 2**63-1: neg pos';
57 # Assume no change whatever; no slop needed
58 tryeq $T++, abs(1e50), 1e50, 'abs(): 1e50: pos pos';
59 # Assume only sign bit flipped
60 tryeq $T++, abs(-1e50), 1e50, 'abs(): 1e50: neg pos';
61
62 my $limit = 1e6;
63
64 # Division (and modulo) of floating point numbers
65 # seem to be rather sloppy in Cray.
66 $limit = 1e8 if $^O eq 'unicos';
67
68 try $T++, abs( 13e21 %  4e21 -  1e21) < $limit, 'abs() for floating point';
69 try $T++, abs(-13e21 %  4e21 -  3e21) < $limit, 'abs() for floating point';
70 try $T++, abs( 13e21 % -4e21 - -3e21) < $limit, 'abs() for floating point';
71 try $T++, abs(-13e21 % -4e21 - -1e21) < $limit, 'abs() for floating point';
72
73 tryeq $T++, 4063328477 % 65535, 27407, 'UV behaves properly: modulo';
74 tryeq $T++, 4063328477 % 4063328476, 1, 'UV behaves properly: modulo';
75 tryeq $T++, 4063328477 % 2031664238, 1, 'UV behaves properly: modulo';
76 tryeq $T++, 2031664238 % 4063328477, 2031664238,
77     'UV behaves properly: modulo';
78
79 tryeq $T++, 2147483647 + 0, 2147483647,
80     'trigger wrapping on 32 bit IVs and UVs';
81
82 tryeq $T++, 2147483647 + 1, 2147483648, 'IV + IV promotes to UV';
83 tryeq $T++, 2147483640 + 10, 2147483650, 'IV + IV promotes to UV';
84 tryeq $T++, 2147483647 + 2147483647, 4294967294, 'IV + IV promotes to UV';
85 tryeq $T++, 2147483647 + 2147483649, 4294967296, 'IV + UV promotes to NV';
86 tryeq $T++, 4294967294 + 2, 4294967296, 'UV + IV promotes to NV';
87 tryeq $T++, 4294967295 + 4294967295, 8589934590, 'UV + UV promotes to NV';
88
89 tryeq $T++, 2147483648 + -1, 2147483647, 'UV + IV promotes to IV';
90 tryeq $T++, 2147483650 + -10, 2147483640, 'UV + IV promotes to IV';
91 tryeq $T++, -1 + 2147483648, 2147483647, 'IV + UV promotes to IV';
92 tryeq $T++, -10 + 4294967294, 4294967284, 'IV + UV promotes to IV';
93 tryeq $T++, -2147483648 + -2147483648, -4294967296, 'IV + IV promotes to NV';
94 tryeq $T++, -2147483640 + -10, -2147483650, 'IV + IV promotes to NV';
95
96 # Hmm. Do not forget the simple stuff
97 # addition
98 tryeq $T++, 1 + 1, 2, 'addition of 2 positive integers';
99 tryeq $T++, 4 + -2, 2, 'addition of positive and negative integer';
100 tryeq $T++, -10 + 100, 90, 'addition of negative and positive integer';
101 tryeq $T++, -7 + -9, -16, 'addition of 2 negative integers';
102 tryeq $T++, -63 + +2, -61, 'addition of signed negative and positive integers';
103 tryeq $T++, 4 + -1, 3, 'addition of positive and negative integer';
104 tryeq $T++, -1 + 1, 0, 'addition which sums to 0';
105 tryeq $T++, +29 + -29, 0, 'addition which sums to 0';
106 tryeq $T++, -1 + 4, 3, 'addition of signed negative and positive integers';
107 tryeq $T++, +4 + -17, -13, 'addition of signed positive and negative integers';
108
109 # subtraction
110 tryeq $T++, 3 - 1, 2, 'subtraction of two positive integers';
111 tryeq $T++, 3 - 15, -12,
112     'subtraction of two positive integers: minuend smaller';
113 tryeq $T++, 3 - -7, 10, 'subtraction of positive and negative integer';
114 tryeq $T++, -156 - 5, -161, 'subtraction of negative and positive integer';
115 tryeq $T++, -156 - -5, -151, 'subtraction of two negative integers';
116 tryeq $T++, -5 - -12, 7,
117     'subtraction of two negative integers: minuend smaller';
118 tryeq $T++, -3 - -3, 0, 'subtraction of two negative integers with result of 0';
119 tryeq $T++, 15 - 15, 0, 'subtraction of two positive integers with result of 0';
120 tryeq $T++, 2147483647 - 0, 2147483647, 'subtraction from large integer';
121 tryeq $T++, 2147483648 - 0, 2147483648, 'subtraction from large integer';
122 tryeq $T++, -2147483648 - 0, -2147483648,
123     'subtraction from large negative integer';
124 tryeq $T++, 0 - -2147483647, 2147483647,
125     'subtraction of large negative integer from 0';
126 tryeq $T++, -1 - -2147483648, 2147483647,
127     'subtraction of large negative integer from negative integer';
128 tryeq $T++, 2 - -2147483648, 2147483650,
129     'subtraction of large negative integer from positive integer';
130 tryeq $T++, 4294967294 - 3, 4294967291, 'subtraction from large integer';
131 tryeq $T++, -2147483648 - -1, -2147483647,
132     'subtraction from large negative integer';
133 tryeq $T++, 2147483647 - -1, 2147483648, 'IV - IV promote to UV';
134 tryeq $T++, 2147483647 - -2147483648, 4294967295, 'IV - IV promote to UV';
135 tryeq $T++, 4294967294 - -3, 4294967297, 'UV - IV promote to NV';
136 tryeq $T++, -2147483648 - +1, -2147483649, 'IV - IV promote to NV';
137 tryeq $T++, 2147483648 - 2147483650, -2, 'UV - UV promote to IV';
138 tryeq $T++, 2000000000 - 4000000000, -2000000000, 'IV - UV promote to IV';
139
140 # No warnings should appear;
141 my $a;
142 $a += 1;
143 tryeq $T++, $a, 1, '+= with positive';
144 undef $a;
145 $a += -1;
146 tryeq $T++, $a, -1, '+= with negative';
147 undef $a;
148 $a += 4294967290;
149 tryeq $T++, $a, 4294967290, '+= with positive';
150 undef $a;
151 $a += -4294967290;
152 tryeq $T++, $a, -4294967290, '+= with negative';
153 undef $a;
154 $a += 4294967297;
155 tryeq $T++, $a, 4294967297, '+= with positive';
156 undef $a;
157 $a += -4294967297;
158 tryeq $T++, $a, -4294967297, '+= with negative';
159
160 my $s;
161 $s -= 1;
162 tryeq $T++, $s, -1, '-= with positive';
163 undef $s;
164 $s -= -1;
165 tryeq $T++, $s, +1, '-= with negative';
166 undef $s;
167 $s -= -4294967290;
168 tryeq $T++, $s, +4294967290, '-= with negative';
169 undef $s;
170 $s -= 4294967290;
171 tryeq $T++, $s, -4294967290, '-= with negative';
172 undef $s;
173 $s -= 4294967297;
174 tryeq $T++, $s, -4294967297, '-= with positive';
175 undef $s;
176 $s -= -4294967297;
177 tryeq $T++, $s, +4294967297, '-= with positive';
178
179 # multiplication
180 tryeq $T++, 1 * 3, 3, 'multiplication of two positive integers';
181 tryeq $T++, -2 * 3, -6, 'multiplication of negative and positive integer';
182 tryeq $T++, 3 * -3, -9, 'multiplication of positive and negative integer';
183 tryeq $T++, -4 * -3, 12, 'multiplication of two negative integers';
184
185 # check with 0xFFFF and 0xFFFF
186 tryeq $T++, 65535 * 65535, 4294836225,
187     'multiplication: 0xFFFF and 0xFFFF: pos pos';
188 tryeq $T++, 65535 * -65535, -4294836225,
189     'multiplication: 0xFFFF and 0xFFFF: pos neg';
190 tryeq $T++, -65535 * 65535, -4294836225,
191     'multiplication: 0xFFFF and 0xFFFF: pos neg';
192 tryeq $T++, -65535 * -65535, 4294836225,
193     'multiplication: 0xFFFF and 0xFFFF: neg neg';
194
195 # check with 0xFFFF and 0x10001
196 tryeq $T++, 65535 * 65537, 4294967295,
197     'multiplication: 0xFFFF and 0x10001: pos pos';
198 tryeq $T++, 65535 * -65537, -4294967295,
199     'multiplication: 0xFFFF and 0x10001: pos neg';
200 tryeq $T++, -65535 * 65537, -4294967295,
201     'multiplication: 0xFFFF and 0x10001: neg pos';
202 tryeq $T++, -65535 * -65537, 4294967295,
203     'multiplication: 0xFFFF and 0x10001: neg neg';
204
205 # check with 0x10001 and 0xFFFF
206 tryeq $T++, 65537 * 65535, 4294967295,
207     'multiplication: 0x10001 and 0xFFFF: pos pos';
208 tryeq $T++, 65537 * -65535, -4294967295,
209     'multiplication: 0x10001 and 0xFFFF: pos neg';
210 tryeq $T++, -65537 * 65535, -4294967295,
211     'multiplication: 0x10001 and 0xFFFF: neg pos';
212 tryeq $T++, -65537 * -65535, 4294967295,
213     'multiplication: 0x10001 and 0xFFFF: neg neg';
214
215 # These should all be dones as NVs
216 tryeq $T++, 65537 * 65537, 4295098369, 'multiplication: NV: pos pos';
217 tryeq $T++, 65537 * -65537, -4295098369, 'multiplication: NV: pos neg';
218 tryeq $T++, -65537 * 65537, -4295098369, 'multiplication: NV: neg pos';
219 tryeq $T++, -65537 * -65537, 4295098369, 'multiplication: NV: neg neg';
220
221 # will overflow an IV (in 32-bit)
222 tryeq $T++, 46340 * 46342, 0x80001218,
223     'multiplication: overflow an IV in 32-bit: pos pos';
224 tryeq $T++, 46340 * -46342, -0x80001218,
225     'multiplication: overflow an IV in 32-bit: pos neg';
226 tryeq $T++, -46340 * 46342, -0x80001218,
227     'multiplication: overflow an IV in 32-bit: neg pos';
228 tryeq $T++, -46340 * -46342, 0x80001218,
229     'multiplication: overflow an IV in 32-bit: neg neg';
230
231 tryeq $T++, 46342 * 46340, 0x80001218,
232     'multiplication: overflow an IV in 32-bit: pos pos';
233 tryeq $T++, 46342 * -46340, -0x80001218,
234     'multiplication: overflow an IV in 32-bit: pos neg';
235 tryeq $T++, -46342 * 46340, -0x80001218,
236     'multiplication: overflow an IV in 32-bit: neg pos';
237 tryeq $T++, -46342 * -46340, 0x80001218,
238     'multiplication: overflow an IV in 32-bit: neg neg';
239
240 # will overflow a positive IV (in 32-bit)
241 tryeq $T++, 65536 * 32768, 0x80000000,
242     'multiplication: overflow a positive IV in 32-bit: pos pos';
243 tryeq $T++, 65536 * -32768, -0x80000000,
244     'multiplication: overflow a positive IV in 32-bit: pos neg';
245 tryeq $T++, -65536 * 32768, -0x80000000,
246     'multiplication: overflow a positive IV in 32-bit: neg pos';
247 tryeq $T++, -65536 * -32768, 0x80000000,
248     'multiplication: overflow a positive IV in 32-bit: neg neg';
249
250 tryeq $T++, 32768 * 65536, 0x80000000,
251     'multiplication: overflow a positive IV in 32-bit: pos pos';
252 tryeq $T++, 32768 * -65536, -0x80000000,
253     'multiplication: overflow a positive IV in 32-bit: pos neg';
254 tryeq $T++, -32768 * 65536, -0x80000000,
255     'multiplication: overflow a positive IV in 32-bit: neg pos';
256 tryeq $T++, -32768 * -65536, 0x80000000,
257     'multiplication: overflow a positive IV in 32-bit: neg neg';
258
259 # 2147483647 is prime. bah.
260
261 tryeq $T++, 46339 * 46341, 0x7ffea80f,
262     'multiplication: hex product: pos pos';
263 tryeq $T++, 46339 * -46341, -0x7ffea80f,
264     'multiplication: hex product: pos neg';
265 tryeq $T++, -46339 * 46341, -0x7ffea80f,
266     'multiplication: hex product: neg pos';
267 tryeq $T++, -46339 * -46341, 0x7ffea80f,
268     'multiplication: hex product: neg neg';
269
270 # leading space should be ignored
271
272 tryeq $T++, 1 + " 1", 2, 'ignore leading space: addition';
273 tryeq $T++, 3 + " -1", 2, 'ignore leading space: subtraction';
274 tryeq $T++, 1.2, " 1.2", 'floating point and string equivalent: positive';
275 tryeq $T++, -1.2, " -1.2", 'floating point and string equivalent: negative';
276
277 # division
278 tryeq $T++, 28/14, 2, 'division of two positive integers';
279 tryeq $T++, 28/-7, -4, 'division of positive integer by negative';
280 tryeq $T++, -28/4, -7, 'division of negative integer by positive';
281 tryeq $T++, -28/-2, 14, 'division of negative integer by negative';
282
283 tryeq $T++, 0x80000000/1, 0x80000000,
284     'division of positive hex by positive integer';
285 tryeq $T++, 0x80000000/-1, -0x80000000,
286     'division of positive hex by negative integer';
287 tryeq $T++, -0x80000000/1, -0x80000000,
288     'division of negative hex by negative integer';
289 tryeq $T++, -0x80000000/-1, 0x80000000,
290     'division of negative hex by positive integer';
291
292 # The example for sloppy divide, rigged to avoid the peephole optimiser.
293 tryeq_sloppy $T++, "20." / "5.", 4, 'division of floating point without fractional part';
294
295 tryeq $T++, 2.5 / 2, 1.25,
296     'division of positive floating point by positive integer';
297 tryeq $T++, 3.5 / -2, -1.75,
298     'division of positive floating point by negative integer';
299 tryeq $T++, -4.5 / 2, -2.25,
300     'division of negative floating point by positive integer';
301 tryeq $T++, -5.5 / -2, 2.75,
302     'division of negative floating point by negative integer';
303
304 # Bluuurg if your floating point can not accurately cope with powers of 2
305 # [I suspect this is parsing string->float problems, not actual arith]
306 tryeq_sloppy $T++, 18446744073709551616/1, 18446744073709551616,
307     'division of very large number by 1'; # Bluuurg
308 tryeq_sloppy $T++, 18446744073709551616/2, 9223372036854775808,
309     'division of very large number by 2';
310 tryeq_sloppy $T++, 18446744073709551616/4294967296, 4294967296,
311     'division of two very large numbers';
312 tryeq_sloppy $T++, 18446744073709551616/9223372036854775808, 2,
313     'division of two very large numbers';
314
315 {
316   # The peephole optimiser is wrong to think that it can substitute intops
317   # in place of regular ops, because i_multiply can overflow.
318   # Bug reported by "Sisyphus" <kalinabears@hdc.com.au>
319   my $n = 1127;
320
321   my $float = ($n % 1000) * 167772160.0;
322   tryeq_sloppy $T++, $float, 21307064320, 'integer times floating point';
323
324   # On a 32 bit machine, if the i_multiply op is used, you will probably get
325   # -167772160. It is actually undefined behaviour, so anything may happen.
326   my $int = ($n % 1000) * 167772160;
327   tryeq $T++, $int, 21307064320, 'integer times integer';
328
329   my $float2 = ($n % 1000 + 0.0) * 167772160;
330   tryeq $T++, $float2, 21307064320, 'floating point times integer';
331
332   my $int2 = ($n % 1000 + 0) * 167772160;
333   tryeq $T++, $int2, 21307064320, 'integer plus zero times integer';
334
335   # zero, but in a way that ought to be able to defeat any future optimizer:
336   my $zero = $$ - $$;
337   my $int3 = ($n % 1000 + $zero) * 167772160;
338   tryeq $T++, $int3, 21307064320, 'defeat any future optimizer';
339
340   my $t = time;
341   my $t1000 = time() * 1000;
342   try $T++, abs($t1000 -1000 * $t) <= 2000, 'absolute value';
343 }
344
345 {
346   # 64 bit variants
347   my $n = 1127;
348
349   my $float = ($n % 1000) * 720575940379279360.0;
350   tryeq_sloppy $T++, $float, 9.15131444281685e+19,
351     '64 bit: integer times floating point';
352
353   my $int = ($n % 1000) * 720575940379279360;
354   tryeq_sloppy $T++, $int, 9.15131444281685e+19,
355     '64 bit: integer times integer';
356
357   my $float2 = ($n % 1000 + 0.0) * 720575940379279360;
358   tryeq_sloppy $T++, $float2, 9.15131444281685e+19,
359     '64 bit: floating point times integer';
360
361   my $int2 = ($n % 1000 + 0) * 720575940379279360;
362   tryeq_sloppy $T++, $int2, 9.15131444281685e+19,
363     '64 bit: integer plus zero times integer';
364
365   # zero, but in a way that ought to be able to defeat any future optimizer:
366   my $zero = $$ - $$;
367   my $int3 = ($n % 1000 + $zero) * 720575940379279360;
368   tryeq_sloppy $T++, $int3, 9.15131444281685e+19,
369     '64 bit: defeat any future optimizer';
370 }
371
372 # [perl #109542] $1 and "$1" should be treated the same way
373 "976562500000000" =~ /(\d+)/;
374 $a = ($1 * 1024);
375 $b = ("$1" * 1024);
376 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" * something\n';
377 $a = (1024 * $1);
378 $b = (1024 * "$1");
379 print "not "x($a ne $b), "ok ", $T++, qq ' - something * \$1 vs "\$1"\n';
380 $a = ($1 + 102400000000000);
381 $b = ("$1" + 102400000000000);
382 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" + something\n';
383 $a = (102400000000000 + $1);
384 $b = (102400000000000 + "$1");
385 print "not "x($a ne $b), "ok ", $T++, qq ' - something + \$1 vs "\$1"\n';
386 $a = ($1 - 10240000000000000);
387 $b = ("$1" - 10240000000000000);
388 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" - something\n';
389 $a = (10240000000000000 - $1);
390 $b = (10240000000000000 - "$1");
391 print "not "x($a ne $b), "ok ", $T++, qq ' - something - \$1 vs "\$1"\n';
392 "976562500" =~ /(\d+)/;
393 $a = ($1 ** 2);
394 $b = ("$1" ** 2);
395 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" ** something\n';
396 "32" =~ /(\d+)/;
397 $a = (3 ** $1);
398 $b = (3 ** "$1");
399 print "not "x($a ne $b), "ok ", $T++, qq ' - something ** \$1 vs "\$1"\n';
400 "97656250000000000" =~ /(\d+)/;
401 $a = ($1 / 10);
402 $b = ("$1" / 10);
403 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" / something\n';
404 "10" =~ /(\d+)/;
405 $a = (97656250000000000 / $1);
406 $b = (97656250000000000 / "$1");
407 print "not "x($a ne $b), "ok ", $T++, qq ' - something / \$1 vs "\$1"\n';
408 "97656250000000000" =~ /(\d+)/;
409 $a = ($1 <=> 97656250000000001);
410 $b = ("$1" <=> 97656250000000001);
411 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" <=> something\n';
412 $a = (97656250000000001 <=> $1);
413 $b = (97656250000000001 <=> "$1");
414 print "not "x($a ne $b), "ok ", $T++, qq ' - something <=> \$1 vs "\$1"\n';
415 "97656250000000001" =~ /(\d+)/;
416 $a = ($1 % 97656250000000002);
417 $b = ("$1" % 97656250000000002);
418 print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" % something\n';
419 $a = (97656250000000000 % $1);
420 $b = (97656250000000000 % "$1");
421 print "not "x($a ne $b), "ok ", $T++, qq ' - something % \$1 vs "\$1"\n';
422
423 my $vms_no_ieee;
424 if ($^O eq 'VMS') {
425   use vars '%Config';
426   eval {require Config; import Config};
427   $vms_no_ieee = 1 unless defined($Config{useieee});
428 }
429
430 if ($^O eq 'vos') {
431   print "not ok ", $T++, " # TODO VOS raises SIGFPE instead of producing infinity.\n";
432 }
433 elsif ($vms_no_ieee) {
434  print $T++, " # SKIP -- the IEEE infinity model is unavailable in this configuration.\n"
435 }
436 elsif ($^O eq 'ultrix') {
437   print "not ok ", $T++, " # TODO Ultrix enters deep nirvana instead of producing infinity.\n";
438 }
439 else {
440   # The computation of $v should overflow and produce "infinity"
441   # on any system whose max exponent is less than 10**1506.
442   # The exact string used to represent infinity varies by OS,
443   # so we don't test for it; all we care is that we don't die.
444   #
445   # Perl considers it to be an error if SIGFPE is raised.
446   # Chances are the interpreter will die, since it doesn't set
447   # up a handler for SIGFPE.  That's why this test is last; to
448   # minimize the number of test failures.  --PG
449
450   my $n = 5000;
451   my $v = 2;
452   while (--$n)
453   {
454     $v *= 2;
455   }
456   print "ok ", $T++, " - infinity\n";
457 }
458
459
460 # [perl #120426]
461 # small numbers shouldn't round to zero if they have extra floating digits
462
463 try $T++,  0.153e-305 != 0.0,              '0.153e-305';
464 try $T++,  0.1530e-305 != 0.0,             '0.1530e-305';
465 try $T++,  0.15300e-305 != 0.0,            '0.15300e-305';
466 try $T++,  0.153000e-305 != 0.0,           '0.153000e-305';
467 try $T++,  0.1530000e-305 != 0.0,          '0.1530000e-305';
468 try $T++,  0.1530001e-305 != 0.0,          '0.1530001e-305';
469 try $T++,  1.17549435100e-38 != 0.0,       'min single';
470 try $T++,  2.2250738585072014e-308 != 0.0, 'min double';
471
472 # string-to-nv should equal float literals
473 try $T++, "1.23"   + 0 ==  1.23,  '1.23';
474 try $T++, " 1.23"  + 0 ==  1.23,  '1.23 with leading space';
475 try $T++, "1.23 "  + 0 ==  1.23,  '1.23 with trailing space';
476 try $T++, "+1.23"  + 0 ==  1.23,  '1.23 with unary plus';
477 try $T++, "-1.23"  + 0 == -1.23,  '1.23 with unary minus';
478 try $T++, "1.23e4" + 0 ==  12300, '1.23e4';
479
480 # trigger various attempts to negate IV_MIN
481
482 tryeq $T++,  0x80000000 / -0x80000000, -1, '(IV_MAX+1) / IV_MIN';
483 tryeq $T++, -0x80000000 /  0x80000000, -1, 'IV_MIN / (IV_MAX+1)';
484 tryeq $T++,  0x80000000 / -1, -0x80000000, '(IV_MAX+1) / -1';
485 tryeq $T++,           0 % -0x80000000,  0, '0 % IV_MIN';
486 tryeq $T++, -0x80000000 % -0x80000000,  0, 'IV_MIN % IV_MIN';