1al_fixadd(3) al_fixadd(3)
2
3
4
6 al_fixadd - Allegro 5 API
7
9 #include <allegro5/allegro.h>
10
11 al_fixed al_fixadd(al_fixed x, al_fixed y);
12
14 Although fixed point numbers can be added with the normal + integer
15 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 5035 into `result'. */
26 result = al_fixadd(al_itofix(5000), al_itofix(35));
27
28 /* Sets errno and puts -32768 into `result'. */
29 result = al_fixadd(al_itofix(-31000), al_itofix(-3000));
30 assert(!al_get_errno()); /* This will fail. */
31
33 Returns the clamped result of adding x to y, setting Allegro's errno to
34 ERANGE if there was an overflow.
35
37 al_fixsub(3), al_fixmul(3), al_fixdiv(3).
38
39
40
41Allegro reference manual al_fixadd(3)