Stress-testing and working on issues

This commit is contained in:
2023-02-27 23:43:56 +11:00
parent f9b154c12e
commit 479e38d492
5 changed files with 28 additions and 28 deletions

View File

@@ -349,8 +349,8 @@ static int nativeRound(Toy_Interpreter* interpreter, Toy_LiteralArray* arguments
}
if (TOY_IS_FLOAT(selfLiteral)) {
//catch the already-rounded case
if (TOY_AS_FLOAT(selfLiteral) == 0) {
result = selfLiteral;
if (TOY_AS_FLOAT(selfLiteral) == (int)TOY_AS_FLOAT(selfLiteral)) {
result = TOY_TO_INTEGER_LITERAL((int)TOY_AS_FLOAT(selfLiteral));
}
else {
result = TOY_TO_INTEGER_LITERAL( TOY_AS_FLOAT(selfLiteral) - (int)TOY_AS_FLOAT(selfLiteral) < 0.5 ? (int)TOY_AS_FLOAT(selfLiteral) : (int)TOY_AS_FLOAT(selfLiteral) + 1 );