1al_fixed(3)                Library Functions Manual                al_fixed(3)
2
3
4

NAME

6       al_fixed
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
25       fixed_point_1 + 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
28       require  a  floating  point coprocessor to use them.  This was great in
29       the time period of i386 and i486 machines, but stopped being so  useful
30       with  the  coming  of  the  Pentium  class of processors.  From Pentium
31       onwards, CPUs have increased their strength in  floating  point  opera‐
32       tions, equaling or even surpassing integer math performance.
33
34       Depending on the type of operations your program may need, using float‐
35       ing point types may be faster than fixed types if you are  targeting  a
36       specific machine class.  Many embedded processors have no FPUs so fixed
37       point maths can be useful there.
38
39
40
41Allegro reference manual                                           al_fixed(3)
Impressum