SDL_round(3)

πŸ’– SDL_round(3) πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_round β€” she's literally just here to round your numbers and look cute doing it ✨


🌸 NAME 🌸

SDL_round β€” round x to the nearest integer, no cap πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_stdinc.h>

double SDL_round(double x);

like. that's the whole vibe. one include, one function, one double. slay πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea, bestie: SDL_round rounds x to the nearest integer. That's it, that's the job 🫢

But wait, there's a lil plot twist for the halfway girlies: values that land exactly halfway between two integers get rounded away from zero. So she's not doing that "round half to even" banker nonsense β€” she's picking a side and committing. main character energy fr fr πŸ’€

Here's the domain and range, because we're thorough in this house:

  • Domain: -INF <= x <= INF
  • Range: -INF <= y <= INF, y integer

And a lil heads up so you don't text the wrong person: this function operates on double-precision floating point values. If you're working with single-precision floats, go hit up SDL_roundf instead. And if you want the result handed back to you as an actual integer type? That's SDL_lround's whole thing. iykyk 😌


🌈 FUNCTION PARAMETERS 🌈

  • x β€” floating point value. just. a float. a lil guy. the number you want rounded πŸ’œ

⭐ RETURN VALUE ⭐

Returns the nearest integer to x. that's the whole delivery, no strings attached, no drama 🎁


🧚 THREAD SAFETY 🧚

It is safe to call this function from any thread. periodt. go wild, call her from everywhere at once, she does not care πŸ’…βœ¨


πŸ‘‘ AVAILABILITY πŸ‘‘

This function is available since SDL 3.2.0. so if you're on anything older... bestie. it's giving ancient. update πŸ’€


πŸ”₯ SEE ALSO πŸ”₯

the whole rounding friend group, all iconic, all in their own pages πŸ’–


Simple Directmedia Layer Β· SDL 3.4.18 β€” and that's the sign-off bestie, mwah, go round some numbers, ily, bye πŸŽ€πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from