Fixed rounding up in SDL_PrintFloat

This wasn't caught by the 9.9999999 case, because that value is actually just equal to 10.0
This commit is contained in:
Brick
2023-08-07 16:33:44 +01:00
committed by Sam Lantinga
parent 75a020aa6b
commit c03f5b4b69
2 changed files with 23 additions and 18 deletions

View File

@@ -1758,16 +1758,17 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do
}
if (num[i] == '9') {
num[i] = '0';
if (i == 0 || num[i - 1] == '-' || num[i - 1] == '+') {
SDL_memmove(&num[i+1], &num[i], length - i);
num[i] = '1';
++length;
break;
}
} else {
++num[i];
break;
}
}
if (i == 0 || num[i] == '-' || num[i] == '+') {
SDL_memmove(&num[i+1], &num[i], length - i);
num[i] = '1';
++length;
}
SDL_assert(length < sizeof(num));
num[length++] = '0';
} else {