SDL_copysignf(3)

πŸ’– SDL_copysignf(3) πŸ’–

okay bestie, we're in the SDL3 FUNCTIONS section of the manual and today's main character is SDL_copysignf β€” she steals a sign from one float and hands it to another. no cap, that's the whole job. 🫢


✨ NAME ✨

SDL_copysignf β€” copy the sign of one floating-point value to another. literally just vibes transplant surgery. πŸ’…


✨ SYNOPSIS ✨

#include <SDL3/SDL_stdinc.h>

float SDL_copysignf(float x, float y);

✨ DESCRIPTION ✨

so the official definition of copysign is giving:

copysign(x, y) = abs(x) * sign(y)

like, take the absolute value of x (strip her of her sign, tragic) and then multiply by the sign of y. that's it. that's the whole tea. πŸ“

Domain: -INF <= x <= INF,

-INF <= y <= f

Range: -INF <= z <= INF

this one is the single-precision girlie β€” she works on single-precision floating point values only. if you need double-precision floats, go hang with SDL_copysign instead. don't mix them up, i'm begging. 😭


✨ FUNCTION PARAMETERS ✨

  • x β€” floating point value to use as the magnitude. she's the how much, not the which way. 🌸
  • y β€” floating point value to use as the sign. she's the which way, not the how much. ✨

✨ RETURN VALUE ✨

returns the floating point value with the sign of y and the magnitude of x. so like… a lil fusion dance of the two. iconic behavior honestly. πŸ‘‘


✨ THREAD SAFETY ✨

it is safe to call this function from any thread. no locks, no drama, no gatekeeping β€” call her from wherever, whenever. 🧚


✨ AVAILABILITY ✨

this function is available since SDL 3.2.0. if your SDL is older than that, bestie… she simply does not exist for you yet. πŸ™ˆ


✨ SEE ALSO ✨

  • SDL_copysign(3) β€” the double-precision sister πŸ’œ
  • SDL_fabsf(3) β€” if you only want the magnitude and not the sign handoff 🌈

okay that's the whole page, you ate that. go forth and copysign responsibly. πŸŽ€

this lil love letter came to you from Simple Directmedia Layer, version SDL 3.4.18, and it's the SDL_copysignf(3) page itself β€” mwah, stay floaty. πŸ’–πŸ¦‹β­

πŸ“¦ where this page comes from