diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c index 2ee62beee..aa57d41b1 100644 --- a/src/stdlib/SDL_stdlib.c +++ b/src/stdlib/SDL_stdlib.c @@ -52,7 +52,12 @@ SDL_ceil(double x) #ifdef HAVE_CEIL return ceil(x); #else - return (double)(int)((x)+0.5); + double integer = SDL_floor(x); + double fraction = x - integer; + if (fraction > 0.0) { + integer += 1.0; + } + return integer; #endif /* HAVE_CEIL */ }