We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3b11dcc commit 4851c7eCopy full SHA for 4851c7e
src/engine/virtualmachine.cpp
@@ -431,8 +431,12 @@ do_loop_end : {
431
432
do_round : {
433
const Value *v = READ_REG(0, 1);
434
- if (!v->isInfinity() && !v->isNegativeInfinity())
435
- REPLACE_RET_VALUE(static_cast<long>(std::round(v->toDouble())), 1);
+ if (!v->isInfinity() && !v->isNegativeInfinity()) {
+ if (v->toDouble() < 0) {
436
+ REPLACE_RET_VALUE(static_cast<long>(std::floor(v->toDouble() + 0.5)), 1);
437
+ } else
438
+ REPLACE_RET_VALUE(static_cast<long>(v->toDouble() + 0.5), 1);
439
+ }
440
DISPATCH();
441
}
442
0 commit comments