SDL_US_TO_NS(3)

✨ SDL_US_TO_NS(3) ✨

okay so bestie, we're in the SDL3 FUNCTIONS corner of the manual and this one is adorable β€” it's a macro, it's tiny, and it does exactly one (1) thing. Let's go πŸ’…


🌸 NAME 🌸

SDL_US_TO_NS β€” convert microseconds to nanoseconds. that's it. that's the whole job. iconic behavior honestly πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_timer.h>

#define SDL_US_TO_NS(US)        (((Uint64)(US)) * SDL_NS_PER_US)

look at her. one line. no notes. πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so what this macro does is take your microseconds and hand them back to you as nanoseconds. glow-up, but for units of time ✨

lowkey important: this only converts whole numbers, not fractional microseconds. so if you were hoping to sneak a 0.5 in there, nope, that's not the vibe this macro is on 🚫

πŸ’œ MACRO PARAMETERS πŸ’œ

  • US β€” the number of microseconds you want converted, bestie.

🌈 RETURN VALUE 🌈

Returns US, expressed in nanoseconds. same number, new unit, main character energy fr fr πŸ’«


πŸ”₯ THREAD SAFETY πŸ”₯

It is safe to call this macro from any thread. no drama, no locks, no anxiety 🫢


⭐ AVAILABILITY ⭐

This macro is available since SDL 3.2.0. so if you're on something older, it's giving "not yet, bestie" 😭


and that's the whole page!! tysm for reading, mwah πŸ’– this was brought to you by the fine folks at Simple Directmedia Layer, running SDL 3.4.18 β€” stay slay, stay converting, and may all your timers be nanosecond-precise πŸ§šβœ¨πŸ‘‘

πŸ“¦ where this page comes from