al_fixdiv(3)

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

πŸ’… al_fixdiv(3) β€” manual crew: Library Functions Manual πŸ’…

okay so bestie, this is al_fixdiv(3) from the Library Functions Manual β€” it’s giving Allegro 5 API, fixed-point division, and one very important errno warning. Let’s get into it. ✨

🌸 NAME 🌸

al_fixdiv β€” Allegro 5 API

✨ SYNOPSIS ✨

#include <allegro5/allegro.h>

al_fixed al_fixdiv(al_fixed x, al_fixed y);

🫢 DESCRIPTION 🫢

okay so here’s the tea: a fixed point value can be divided by an integer with the normal / operator. But to divide two fixed point values? You must use this function, no cap.

⚠️ If a division by zero occurs, Allegro’s errno will be set and the maximum possible value will be returned. But β€” and this is the important bit β€” errno is not cleared if the operation is successful. So if you’re gonna test for division by zero, call al_set_errno(0) before calling al_fixdiv(3). πŸ’€

Example, bestie:

al_fixed result;

/* This will put 0.06060 `result'. */
result = al_fixdiv(al_itofix(2), al_itofix(33));

/* This will put 0 into `result'. */
result = al_fixdiv(0, al_itofix(-30));

/* Sets errno and puts -32768 into `result'. */
result = al_fixdiv(al_itofix(-100), al_itofix(0));
assert(!al_get_errno()); /* This will fail. */

🚨 RETURN VALUE 🚨

It returns the result of dividing x by y. If y is zero, it returns the maximum possible fixed point value and sets Allegro’s errno to ERANGE. periodt. πŸ’–

πŸ”₯ SEE ALSO πŸ”₯

al_fixadd(3), al_fixsub(3), al_fixmul(3), al_get_errno(3).


πŸ’– that’s the whole page, bestie β€” source: Allegro reference manual; page: al_fixdiv(3). The footer didn’t list a date, so no fake date energy here. mwah πŸ’‹

πŸ“¦ 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