Skip to content

Commit aee3d95

Browse files
committed
Fix a logic error returning wrong values for sin(0.25) and sin(0.75)
1 parent e9a5c2d commit aee3d95

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lpico8lib.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ static lua_Number sin_helper(lua_Number x) {
6565
// - the last two bits are rounded
6666
// We use a lookup table of sin(x)-4x generated by PICO-8 to ensure
6767
// that we get the exact same results.
68-
auto a = ((x.bits() & 0x4000 ? ~x : x).bits() + 2) & 0x3ffc;
69-
auto ret = lua_Number::frombits(4 * a + sintable[a >> 2]);
68+
auto a = ((x.bits() & 0x4000 ? ~x : x).bits() & 0x3fff) + 2;
69+
auto ret = lua_Number::frombits((a >> 2 << 4) + sintable[a >> 2]);
7070
return x.bits() & 0x8000 ? ret : -ret;
7171
}
7272

0 commit comments

Comments
 (0)