1al_fixsub(3)                                                      al_fixsub(3)
2
3
4

NAME

6       al_fixsub - Allegro 5 API
7

SYNOPSIS

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

DESCRIPTION

14       Although  fixed point numbers can be subtracted with the normal - inte‐
15       ger operator, that doesn’t provide any protection against overflow.  If
16       overflow  is  a  problem,  you should use this function instead.  It is
17       slower than using integer operators, but if an overflow occurs it  will
18       set  Allegro’s  errno and clamp the result, rather than just letting it
19       wrap.
20
21       Example:
22
23              al_fixed result;
24
25              /* This will put 4965 into `result'. */
26              result = al_fixsub(al_itofix(5000), al_itofix(35));
27
28              /* Sets errno and puts -32768 into `result'. */
29              result = al_fixsub(al_itofix(-31000), al_itofix(3000));
30              assert(!al_get_errno()); /* This will fail. */
31

RETURN VALUE

33       Returns the clamped result of subtracting y from x,  setting  Allegro’s
34       errno to ERANGE if there was an overflow.
35

SEE ALSO

37       al_fixadd(3), al_fixmul(3), al_fixdiv(3), al_get_errno(3).
38
39
40
41Allegro reference manual                                          al_fixsub(3)
Impressum