1al_fixadd(3)                                                      al_fixadd(3)
2
3
4

NAME

6       al_fixadd - Allegro 5 API
7

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

SEE ALSO

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