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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms