> [EMAIL PROTECTED] - Thu Jan 04 10:10:18 2001]:
> 
> # The following complete four-line perl script produces unexpected
> # results on my machine.  The multiplication in the second line of
> # code below produces a negative result where a positive number is
> # expected, presumably because an integer multiplication was used
> # internally where a floating point operation was needed.  If the
> # expression is broken up and evaluated piece by piece then the
> # correct result is produced (line 4). (The difference between the two
> # results is, naturally, 2**32.)  The same results were produced under
> # perl v5.6.0.
> 
> my ($p, $x, $y) = (65537, 64645, 34463);
> print (($x % $p) * ($y % $p), "\n");     # produces -2067106661
> (incorrect)
> my ($a, $b) = ($x % $p, $y % $p);
> print $a * $b, "\n";                     # produces  2227860635
> (correct)

Confirmed broken in 5.6.2.

Confirmed fixed in 5.8.0.


0 windhund ~/tmp$ perl5.6.2 test
-2067106661
2227860635
0 windhund ~/tmp$ perl5.5.4 test
-2067106661
2227860635
0 windhund ~/tmp$ perl5.8.6 test
2227860635
2227860635
0 windhund ~/tmp$ perl5.8.0 test
2227860635
2227860635
0 windhund ~/tmp$ perl5.8.1 test
2227860635
2227860635

Reply via email to