SDL School

API reference / Math

SDL_floorf

Function, SDL3

Rounds a float down to a whole number.

Declaration

#include <SDL3/SDL.h>

float SDL_floorf(float x);

Parameters

xThe value.

Return value

The largest whole number that is not above x.

Example

Platformer
int left = (int)SDL_floorf(x / TILE_SIZE);

See this code run in Platformer. Download the full program (.zip)

In SDL2

The name is the same.