mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-23 14:31:56 +00:00
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:
parent
75a020aa6b
commit
c03f5b4b69
2 changed files with 23 additions and 18 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue