1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
.TH al_fixed 3 "" "Allegro reference manual"
.SH NAME
.PP
al_fixed \- Allegro 5 API
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <allegro5/allegro.h>
typedef\ int32_t\ al_fixed;
\f[]
.fi
.SH DESCRIPTION
.PP
A fixed point number.
.PP
Allegro provides some routines for working with fixed point numbers, and
defines the type \f[C]al_fixed\f[] to be a signed 32\-bit integer.
The high word is used for the integer part and the low word for the
fraction, giving a range of \-32768 to 32767 and an accuracy of about
four or five decimal places.
Fixed point numbers can be assigned, compared, added, subtracted,
negated and shifted (for multiplying or dividing by powers of two) using
the normal integer operators, but you should take care to use the
appropriate conversion routines when mixing fixed point with integer or
floating point values.
Writing \f[C]fixed_point_1\ +\ fixed_point_2\f[] is OK, but
\f[C]fixed_point\ +\ integer\f[] is not.
.PP
The only advantage of fixed point math routines is that you don\[aq]t
require a floating point coprocessor to use them.
This was great in the time period of i386 and i486 machines, but stopped
being so useful with the coming of the Pentium class of processors.
From Pentium onwards, CPUs have increased their strength in floating
point operations, equaling or even surpassing integer math performance.
.PP
Depending on the type of operations your program may need, using
floating point types may be faster than fixed types if you are targeting
a specific machine class.
Many embedded processors have no FPUs so fixed point maths can be useful
there.
|