lambdamoo icon indicating copy to clipboard operation
lambdamoo copied to clipboard

Power operator is broken for −1^b when b < 0

Open verement opened this issue 11 years ago • 0 comments

The following change to the numbers.c function do_power() is erroneous:

-               ans.v.num = (b % 2 == 0 ? 1 : -1);
+               ans.v.num = (b & 1) ? 1 : -1;

As a result, negative powers of −1 have the wrong sign.

verement avatar Jan 18 '14 20:01 verement