verement / lambdamoo

The LambdaMOO server (with Unicode support)
http://codepoint.the-b.org/
18 stars 2 forks source link

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

Open verement opened 10 years ago

verement commented 10 years ago

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.