fixsqrt(3alleg4)

πŸ’– fixsqrt β€” bestie edition πŸ’–

okay so this is a page from the Allegro manual, section 3alleg4 β€” it's the fixed point square root situation, and yes it's part of the Allegro game programming library. sit down, hydrate, let's go 🫢


✨ SYNOPSIS ✨

#include <allegro.h>

fixed fixsqrt(fixed x);

literally that's it. one function. one job. she's simple, she's efficient, she's an icon πŸ’…


🌸 DESCRIPTION 🌸

so fixsqrt finds the non negative square root of x. that's the whole vibe β€” you hand her a fixed value, she hands you back the square root of it. slay ✨

but here's the part where you gotta pay attention bestie πŸ‘€ β€” if x is negative, it does NOT just wing it. no ma'am. instead:

  • errno gets set to EDOM πŸ’€
  • and the function returns zero

so like. if you're out here passing negative numbers and then wondering why you got a 0 back, that's not a bug, that's the function being honest with you. check your errno, bestie, she's trying to tell you something 😭

fr fr: negative input = EDOM in errno + a 0 return value. no cap.

πŸ‘‘ SEE ALSO πŸ‘‘

the rest of the girlies in this friend group:

(yes the comma at the front is in the original, she's just quirky like that πŸ™ˆ)

πŸŽ€ sign-off πŸŽ€

this page is from Allegro, version 4.4.3, and it belongs to the fixsqrt(3alleg4) manual page. go forth and square root responsibly, you absolute main character πŸŒˆπŸ’–βœ¨