Skip to content

Commit 8bf0cf3

Browse files
committed
VirtualMachine: Fix tangent of negative numbers
1 parent 4851c7e commit 8bf0cf3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/engine/virtualmachine.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ do_tan : {
495495
if (v->isInfinity() || v->isNegativeInfinity())
496496
REPLACE_RET_VALUE(Value(Value::SpecialValue::NaN), 1);
497497
else {
498-
long mod = v->toLong() % 360;
498+
long mod;
499+
if (v->toLong() < 0)
500+
mod = (v->toLong() + 360) % 360;
501+
else
502+
mod = v->toLong() % 360;
499503
if (mod == 90)
500504
REPLACE_RET_VALUE(Value(Value::SpecialValue::Infinity), 1);
501505
else if (mod == 270)

0 commit comments

Comments
 (0)