Skip to content

Commit c1a9535

Browse files
committed
VirtualMachine: Fix atan of infinity
1 parent 8bf0cf3 commit c1a9535

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/engine/virtualmachine.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,10 @@ do_acos : {
530530

531531
do_atan : {
532532
const Value &v = *READ_REG(0, 1);
533-
if (v < -1 || v > 1)
534-
REPLACE_RET_VALUE(Value(Value::SpecialValue::NaN), 1);
533+
if (v.isInfinity())
534+
REPLACE_RET_VALUE(90, 1);
535+
else if (v.isNegativeInfinity())
536+
REPLACE_RET_VALUE(-90, 1);
535537
else
536538
REPLACE_RET_VALUE(std::atan(v.toDouble()) * 180 / pi, 1);
537539
DISPATCH();

0 commit comments

Comments
 (0)