al_ftofix(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸŽ€ NAME πŸŽ€

al_ftofix β€” Allegro 5 API. This page is from the Library Functions Manual, bestie, and it’s giving β€œfloat goes fixed-point” energy πŸ’…βœ¨

πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro5/allegro.h>

al_fixed al_ftofix(double x);

🌸 DESCRIPTION 🌸

Okay so al_ftofix converts a floating point value to fixed point. Unlike al_itofix(3), this function clamps values which could overflow the type conversion, setting Allegro’s errno to ERANGE in the process if this happens. No cap, that clamp is the whole personality 🫢

Example, copied exactly because we do not mess with code:

al_fixed number;

number = al_itofix(-40000);
assert(al_fixfloor(number) == -32768);

number = al_itofix(64000);
assert(al_fixfloor(number) == 32767);
assert(!al_get_errno()); /* This will fail. */

🌈 RETURN VALUE 🌈

Returns the value of the floating point value converted to fixed point clamping overflows (and setting Allegro’s errno). So you get the converted value back, plus the errno side-eye when overflow clamping kicks in 😭✨

πŸ‘‘ SEE ALSO πŸ‘‘


Source/version cutie: Allegro reference manual; page tag: al_ftofix(3); date: not listed in the footer, bestie πŸ«ΆπŸ’–

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms