SDL_NS_TO_US(3)

πŸ’– SDL_NS_TO_US πŸ’–

okay bestie, welcome to SDL3 FUNCTIONS, and today's main character is SDL_NS_TO_US(3) β€” she converts nanoseconds to microseconds and she does it with zero drama. ✨


🌸 NAME 🌸

SDL_NS_TO_US β€” convert nanoseconds to microseconds, no cap.


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_timer.h>

#define SDL_NS_TO_US(NS)        ((NS) / SDL_NS_PER_US)

πŸ¦‹ DESCRIPTION πŸ¦‹

so this one is literally just a division, okay? it takes your nanoseconds and divides them down into microseconds, and that's the whole plot. iconic behavior, honestly.

BUT β€” and this is the part where you gotta listen to me β€” because it performs a division, the results can be dramatically different depending on whether NS is an integer or a floating point value. like, dramatically dramatically. 🫠 so know what you're feeding her, bestie.


πŸ’… MACRO PARAMETERS πŸ’…

  • NS β€” the number of nanoseconds you wanna convert. that's it, that's the input. πŸ“

⭐ RETURN VALUE ⭐

returns NS, but expressed in microseconds. glow up complete. πŸ‘‘


🌈 THREAD SAFETY 🌈

it is safe to call this macro from any thread. every thread gets a turn, we don't gatekeep. 🫢


✨ AVAILABILITY ✨

this macro is available since SDL 3.2.0. if you're on something older... girl. 😭


and that's the whole page! go forth and divide responsibly. πŸ’œ

mwah πŸ’‹ β€” brought to you by Simple Directmedia Layer, running SDL 3.4.18. periodt.

πŸ“¦ where this page comes from