.\" Automatically generated by Pandoc 3.1.12.1 .\" .TH "al_fixadd" "3" "" "Allegro reference manual" "" .SH NAME al_fixadd \- Allegro 5 API .SH SYNOPSIS .IP .EX #include \f[B]\f[R] al_fixed al_fixadd(al_fixed x, al_fixed y); .EE .SH DESCRIPTION Although fixed point numbers can be added with the normal \f[CR]+\f[R] integer operator, that doesn\[cq]t provide any protection against overflow. If overflow is a problem, you should use this function instead. It is slower than using integer operators, but if an overflow occurs it will set Allegro\[cq]s errno and clamp the result, rather than just letting it wrap. .PP Example: .IP .EX al_fixed result; \f[I]/* This will put 5035 into \[ga]result\[aq]. */\f[R] result = al_fixadd(al_itofix(5000), al_itofix(35)); \f[I]/* Sets errno and puts \-32768 into \[ga]result\[aq]. */\f[R] result = al_fixadd(al_itofix(\-31000), al_itofix(\-3000)); assert(!al_get_errno()); \f[I]/* This will fail. */\f[R] .EE .SH RETURN VALUE Returns the clamped result of adding \f[CR]x\f[R] to \f[CR]y\f[R], setting Allegro\[cq]s errno to ERANGE if there was an overflow. .SH SEE ALSO al_fixsub(3), al_fixmul(3), al_fixdiv(3).