SDL_NS_TO_SECONDS(3)

πŸ’– SDL_NS_TO_SECONDS πŸ’–

okay bestie, welcome to the SDL3 functions manual, page for SDL_NS_TO_SECONDS(3) β€” yes that's the one, you found it, you're doing amazing 🫢

✨ NAME ✨

SDL_NS_TO_SECONDS β€” convert nanoseconds to seconds. that's it. that's the whole job. she's simple, she's iconic, she's a macro πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_timer.h>

#define SDL_NS_TO_SECONDS(NS)   ((NS) / SDL_NS_PER_SECOND)

look at her. one line. no notes. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so what she does is divide. that's the whole vibe. you hand her some nanoseconds, she hands you back seconds, periodt.

BUT β€” and this is the part where you gotta pay attention bestie, no cap β€” because it's literally just a division, the results can be dramatically different depending on whether NS is an integer or a floating point value. like, not a little different. dramatically different. the way that one type versus the other changes everything?? yeah. keep that in mind, iykyk πŸ’€


πŸŽ€ MACRO PARAMETERS πŸŽ€

  • NS β€” the number of nanoseconds you wanna convert, girl. hand it over. πŸ™ˆ

⭐ RETURN VALUE ⭐

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


🌈 THREAD SAFETY 🌈

it is safe to call this macro from any thread. any. thread. she does not care. she is unbothered. she is thriving. πŸ’œ


πŸ‘‘ AVAILABILITY πŸ‘‘

this macro has been available since SDL 3.2.0. so if you're on something older, sorry babe, you're not invited to the function 😭


ok real talk though β€” the integer vs floating point thing is the actual plot twist of this page. don't skip it. fr fr.

Simple Directmedia Layer πŸ¦‹ SDL 3.4.18 β€” that's the source and the version, mwah, thanks for reading bestie, go convert some nanoseconds, you ate πŸ’…βœ¨

πŸ“¦ where this page comes from