mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-06 01:46:25 +00:00
stdlib: Add SDL_trunc and SDL_truncf
This commit is contained in:
@@ -761,3 +761,5 @@
|
||||
#define SDL_UnlockSensors SDL_UnlockSensors_REAL
|
||||
#define SDL_Metal_GetLayer SDL_Metal_GetLayer_REAL
|
||||
#define SDL_Metal_GetDrawableSize SDL_Metal_GetDrawableSize_REAL
|
||||
#define SDL_trunc SDL_trunc_REAL
|
||||
#define SDL_truncf SDL_truncf_REAL
|
||||
|
@@ -820,3 +820,5 @@ SDL_DYNAPI_PROC(void,SDL_LockSensors,(void),(),)
|
||||
SDL_DYNAPI_PROC(void,SDL_UnlockSensors,(void),(),)
|
||||
SDL_DYNAPI_PROC(void*,SDL_Metal_GetLayer,(SDL_MetalView a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_Metal_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),)
|
||||
SDL_DYNAPI_PROC(double,SDL_trunc,(double a),(a),return)
|
||||
SDL_DYNAPI_PROC(float,SDL_truncf,(float a),(a),return)
|
||||
|
@@ -260,6 +260,27 @@ SDL_floorf(float x)
|
||||
#endif
|
||||
}
|
||||
|
||||
double
|
||||
SDL_trunc(double x)
|
||||
{
|
||||
#if defined(HAVE_TRUNC)
|
||||
return trunc(x);
|
||||
#else
|
||||
/* !!! FIXME: there are more formal (correct!) ways to do this. */
|
||||
return (double) ((Sint64) x);
|
||||
#endif
|
||||
}
|
||||
|
||||
float
|
||||
SDL_truncf(float x)
|
||||
{
|
||||
#if defined(HAVE_TRUNCF)
|
||||
return truncf(x);
|
||||
#else
|
||||
return (float)SDL_trunc((double)x);
|
||||
#endif
|
||||
}
|
||||
|
||||
double
|
||||
SDL_fmod(double x, double y)
|
||||
{
|
||||
|
Reference in New Issue
Block a user