SDL_lroundf(3)

πŸ’– SDL_lroundf(3) πŸ’–

okay bestie, welcome to the SDL3 functions corner of the manual, pull up a chair πŸŽ€ this one's a lil math baddie and honestly? she's serving.


✨ NAME ✨

SDL_lroundf β€” round x to the nearest integer representable as a long πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_stdinc.h>

long SDL_lroundf(float x);

✨ DESCRIPTION ✨

So here's the vibe: this function rounds x to the nearest integer. no cap, that's the whole job. 🫢

but bestie, the tea is in the halfway case β€” values that land exactly halfway between two integers get rounded away from zero. so no wishy-washy banker's rounding nonsense here, she picks a side and commits. main character energy fr fr πŸ‘‘

the domain of this queen is:

  • Domain: -INF <= x <= INF
  • Range: MIN_LONG <= y <= MAX_LONG

also important, she's a single-precision girlie. if you're working with double-precision floats, go hang with SDL_lround instead. and if what you actually want is the result as a floating-point type (not a long), you want SDL_roundf. know your options, iykyk 🌸


✨ FUNCTION PARAMETERS ✨

  • x β€” floating point value. that's it. that's the input. she takes one (1) float and she takes it seriously πŸ’–

✨ RETURN VALUE ✨

returns the nearest integer to x. simple, iconic, no notes. ✨


✨ THREAD SAFETY ✨

it is safe to call this function from any thread. yes bestie, any thread, go wild, she's not gonna get weird about it 🌈


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. so if you're on something older... 😭 sorry babe.


✨ SEE ALSO ✨


and that's the whole page, bestie!! this was brought to you by Simple Directmedia Layer πŸ’œ running the SDL 3.4.18 era of things β€” go round some floats, slay, and remember: halfway values go away from zero, not toward it. periodt. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from