fixmul(3)
π fixmul β the Allegro manual, but make it cute π
okay bestie, we're in the Allegro manual today and the function on the menu is fixmul(3) π she multiplies two fixed point values together, and honestly? she's iconic for it. Allegro game programming library, let's GO π¦
β¨ NAME β¨
fixmul β multiplies two fixed point values together. Allegro game programming library. no cap, that's the whole job description π
πΈ SYNOPSIS πΈ
#include <allegro.h>
fixed fixmul(fixed x, fixed y);
π DESCRIPTION π
so here's the tea π a fixed point value can be multiplied or divided by an integer using the normal * and / operators, easy peasy, love that for you.
BUT. if you wanna multiply two fixed point values together? you literally have to use this function. the operators will not save you here, bestie π
if an overflow happens, errno gets set and the maximum possible value gets returned. and here's the sneaky part β errno is not cleared if the operation is successful π so if you're planning to actually test for overflow, you should set errno=0 before calling fixmul(). it's giving "set the vibe before you walk in the room." example time:
fixed result;
/* This will put 30000 into `result'. */
result = fixmul(itofix(10), itofix(3000));
/* But this overflows, and sets `errno'. */
result = fixmul(itofix(100), itofix(3000));
ASSERT(!errno);
see how the first one's just chilling and the second one is spiraling? yeah. that's the whole bit π
β RETURN VALUE β
she returns the clamped result of multiplying x by y, and she sets errno to ERANGE if there was an overflow. so if you see ERANGE, you know exactly what happened, no mystery, no drama π
π«Ά SEE ALSO π«Ά
go read those next, they're all part of the same lil fixed point family π
and that's the page, bestie!! this was Allegro version 4.4.3, page fixmul(3), and yes you read all of it which means you're lowkey a fixed point girlie now πβ¨ slay, periodt, go multiply responsibly ππ¦
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms