Change 20167 by [EMAIL PROTECTED] on 2003/07/18 06:14:33 Subject: [PATCH] Re: Oops - Can't calculate our powers From: Stephen McCamant <[EMAIL PROTECTED]> Date: Fri, 18 Jul 2003 02:26:14 -0400 Message-ID: <[EMAIL PROTECTED]>
Affected files ... ... //depot/perl/pp.c#388 edit ... //depot/perl/t/op/pow.t#2 edit Differences ... ==== //depot/perl/pp.c#388 (text) ==== Index: perl/pp.c --- perl/pp.c#387~19843~ Sun Jun 22 10:00:10 2003 +++ perl/pp.c Thu Jul 17 23:14:33 2003 @@ -972,6 +972,7 @@ register unsigned int highbit = 8 * sizeof(UV); register unsigned int lowbit = 0; register unsigned int diff; + bool odd_power = (power & 1); while ((diff = (highbit - lowbit) >> 1)) { if (baseuv & ~((1 << (lowbit + diff)) - 1)) lowbit += diff; @@ -994,7 +995,7 @@ } } SP--; - if (baseuok || !(power & 1)) + if (baseuok || !odd_power) /* answer is positive */ SETu( result ); else if (result <= (UV)IV_MAX) ==== //depot/perl/t/op/pow.t#2 (text) ==== Index: perl/t/op/pow.t --- perl/t/op/pow.t#1~15267~ Sat Mar 16 11:57:03 2002 +++ perl/t/op/pow.t Thu Jul 17 23:14:33 2003 @@ -16,7 +16,10 @@ my $tests; $tests += $_->[1] foreach @pow; -plan tests => 1 + $bits_in_uv + $tests; +plan tests => 2 + $bits_in_uv + $tests; + +# This gave positive 27 before change #20167 +is((-3)**3, -27, "(negative int) ** (odd power) is negative"); # Ought to be 32, 64, 36 or something like that. End of Patch.