1al_fixdiv(3)               Library Functions Manual               al_fixdiv(3)
2
3
4

NAME

6       al_fixdiv
7

SYNOPSIS

9              #include <allegro5/allegro.h>
10
11              al_fixed al_fixdiv(al_fixed x, al_fixed y);
12

DESCRIPTION

14       A  fixed  point  value  can  be divided by an integer with the normal /
15       operator.  To divide two fixed point values, though, you must use  this
16       function.   If  a  division by zero occurs, Allegro's errno will be set
17       and the maximum possible value will  be  returned,  but  errno  is  not
18       cleared  if  the  operation  is successful.  This means that if you are
19       going to test for division by  zero  you  should  call  al_set_errno(0)
20       before calling al_fixdiv(3).
21
22       Example:
23
24                  al_fixed result;
25
26                  /* This will put 0.06060 `result'. */
27                  result = al_fixdiv(al_itofix(2), al_itofix(33));
28
29                  /* This will put 0 into `result'. */
30                  result = al_fixdiv(0, al_itofix(-30));
31
32                  /* Sets errno and puts -32768 into `result'. */
33                  result = al_fixdiv(al_itofix(-100), al_itofix(0));
34                  assert(!al_get_errno()); /* This will fail. */
35

RETURN VALUE

37       Returns the result of dividing x by y.  If y is zero, returns the maxi‐
38       mum possible fixed point value and sets Allegro's errno to ERANGE.
39

SEE ALSO

41       al_fixadd(3), al_fixsub(3), al_fixmul(3), al_get_errno(3).
42
43
44
45Allegro reference manual                                          al_fixdiv(3)
Impressum