SDL_truncf(3)

πŸ’– SDL_truncf πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, page SDL_truncf(3), and honestly? this one is so chill. it's giving "small function, big slay." let's get into it πŸŽ€


✨ NAME ✨

SDL_truncf β€” chop x down to an integer, fr fr.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

float SDL_truncf(float x);

πŸ¦‹ DESCRIPTION πŸ¦‹

so what it does is: it rounds x to the next closest integer toward 0. same energy as just deleting the fractional part of x and leaving the integer part sitting there all alone. like, the decimal gets ghosted. πŸ’…

Domain: -INF <= x <= INF

Range: -INF <= y <= INF, y integer

heads up though β€” this one is strictly for single-precision floating point values. if you're on that double-precision grind, you want SDL_trunc instead. iykyk ✨


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • x β€” a floating point value. that's it. that's the whole parameter. icon behavior.

πŸ’œ RETURN VALUE πŸ’œ

returns x truncated to an integer. no drama, no surprises, just vibes. 🌈


🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. go wild, bestie. multithread it. it does not care. 🫢


⭐ AVAILABILITY ⭐

this function has been available since SDL 3.2.0. so if you're on anything older… yeah, no. update. 😭


πŸ‘‘ SEE ALSO πŸ‘‘


ok real talk, this is your friendly reminder that all the rounding cousins exist and each one rounds a different direction. don't just grab the first one you see. vibe check your rounding. πŸ”₯

and that's the whole page!! this little baddie ships with Simple Directmedia Layer, SDL 3.4.18 edition β€” that's the source and the version, bestie, so you know exactly what you're working with. go truncate something. slay. πŸ’–βœ¨πŸŒΈπŸ¦‹πŸŽ€πŸ’…πŸ«Ά

πŸ“¦ where this page comes from