SDL_NS_TO_MS(3)

✨ SDL_NS_TO_MS ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual πŸ’– this one's called SDL_NS_TO_MS and she's a tiny little macro with a big job.


🌸 NAME 🌸

SDL_NS_TO_MS β€” convert nanoseconds to milliseconds. that's it. that's the whole girl. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_timer.h>

#define SDL_NS_TO_MS(NS)        ((NS) / SDL_NS_PER_MS)

look at her πŸ¦‹ one #include, one #define, no drama.


πŸ’œ DESCRIPTION πŸ’œ

So basically, this macro does a division. simple right? NOT SO FAST 😭

The way that it's just (NS) / SDL_NS_PER_MS means the result can be dramatically different depending on whether NS is an integer or a floating point value. like, actually dramatically. not a little bit. dramatically. πŸ‘€

Integer division and floating point division are not the same vibe, and this macro does not care. it just divides. iykyk. πŸ™ˆ


🧚 MACRO PARAMETERS 🧚

  • NS β€” the number of nanoseconds you wanna convert, bb. that's the input. that's the whole input. 🌸

⭐ RETURN VALUE ⭐

Returns NS, expressed in milliseconds. πŸ’–

she gives back what you gave her, just in a different unit. glow up. ✨


πŸ‘‘ THREAD SAFETY πŸ‘‘

It is safe to call this macro from any thread. 🫢

no locks, no worries, no main character fights over shared state. every thread can have her. πŸ’…


🌈 AVAILABILITY 🌈

This macro is available since SDL 3.2.0. so if you're on something older... bestie. upgrade. 😭


and that's the tea πŸ“ go forth and convert your nanoseconds, you absolute icon. ⭐

mwah πŸ’– this page came to you from the Simple Directmedia Layer, running SDL 3.4.18, and yeah it's SDL_NS_TO_MS(3) β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from