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
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms