al_fixmul(3alleg5)
π al_fixmul β the Allegro 5 API page, bestie edition π
okay so this is al_fixmul from the allegro5 manual (that's the manual name, in case you were wondering, and yes we're doing this whole thing together) π
β¨ NAME β¨
al_fixmul β Allegro 5 API
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
al_fixed al_fixmul(al_fixed x, al_fixed y);
π¦ DESCRIPTION π¦
okay so here's the tea, bestie π β a fixed point value can be multiplied or divided by an integer using the normal * and / operators. easy, right? no thoughts, head empty, just vibes.
BUT π β if you wanna multiply two fixed point values together? nope. you must use this function. there is no other way. this is the only way. periodt.
now for the part that will lowkey ruin your day if you ignore it π β if an overflow happens, Allegro's errno gets set, and the maximum possible value gets returned. cute, right? except here's the catch: errno is not cleared if the operation is successful. so if you're planning to actually test for overflow, you have to call al_set_errno(0) before you call al_fixmul(3alleg5). otherwise you're out here checking an errno from three functions ago and living a lie. do not do that to yourself π
Example:
al_fixed result;
/* This will put 30000 into `result'. */
result = al_fixmul(al_itofix(10), al_itofix(3000));
/* But this overflows, and sets errno. */
result = al_fixmul(al_itofix(100), al_itofix(3000));
assert(!al_get_errno());
π RETURN VALUE π
it returns the clamped result of multiplying x by y, and it sets Allegro's errno to ERANGE if there was an overflow. so like, no silent nonsense, it tells on itself, iconic behaviour honestly β¨
π SEE ALSO π
and that's the whole page, bestie π«Ά this came to you straight from the Allegro reference manual, page al_fixmul(3alleg5) β go forth and multiply your fixed point values responsibly πβ¨π
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms