al_fixdiv(3)
π
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βserrnowill be set and the maximum possible value will be returned. But β and this is the important bit βerrnois not cleared if the operation is successful. So if youβre gonna test for division by zero, callal_set_errno(0)before callingal_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