1al_fixed(3)                                                        al_fixed(3)
2
3
4

NAME

6       al_fixed - Allegro 5 API
7

SYNOPSIS

9              #include <allegro5/allegro.h>
10
11              typedef int32_t al_fixed;
12

DESCRIPTION

14       A fixed point number.
15
16       Allegro  provides  some  routines for working with fixed point numbers,
17       and defines the type al_fixed to be a signed 32-bit integer.  The  high
18       word  is  used  for the integer part and the low word for the fraction,
19       giving a range of -32768 to 32767 and an accuracy of about four or five
20       decimal  places.  Fixed point numbers can be assigned, compared, added,
21       subtracted, negated and shifted (for multiplying or dividing by  powers
22       of two) using the normal integer operators, but you should take care to
23       use the appropriate conversion routines when mixing  fixed  point  with
24       integer   or   floating   point   values.    Writing   fixed_point_1  +
25       fixed_point_2 is OK, but fixed_point + integer is not.
26
27       The only advantage of fixed point math routines is that you  don’t  re‐
28       quire  a floating point coprocessor to use them.  This was great in the
29       time period of i386 and i486 machines, but stopped being so useful with
30       the  coming  of the Pentium class of processors.  From Pentium onwards,
31       CPUs have increased their strength in floating point operations, equal‐
32       ing  or even surpassing integer math performance.  However, many embed‐
33       ded processors have no FPUs so fixed point maths can  still  be  useful
34       there.
35
36       Depending on the type of operations your program may need, using float‐
37       ing point types may be faster than fixed types if you are  targeting  a
38       specific machine class.
39
40
41
42Allegro reference manual                                           al_fixed(3)
Impressum