Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

Fix Class Reference
[Maths - 32bit Fixed-Point Maths]

#include <fix.h>

List of all members.


Detailed Description

Fixed point arithmetic functions.

Operands are 32 bits in size with the binary point between bits 15 and 16.

See also:
fix ufix fixangle
Version:
2005-02-26

Definition at line 160 of file fix.h.

Static Public Member Functions

static IMPORT fix Add (fix a, fix b)
static IMPORT fix Sub (fix a, fix b)
static IMPORT fix Mul (fix a, fix b)
static IMPORT fix MulNS (fix a, fix b)
static IMPORT fix Div (fix a, fix b)
static IMPORT fix Sqrt (ufix a)
static IMPORT fix Log2 (ufix a)
static IMPORT ufix Exp2 (fix a)
static IMPORT fix Sin (fixangle angle)
static IMPORT fix Cos (fixangle angle)
static IMPORT fix Tan (fixangle angle)
static IMPORT fixangle ASin (fix value)
static IMPORT fixangle ACos (fix value)
static IMPORT fixangle ATan (fix value)
static IMPORT fix Random (uint32_t &seed)
static IMPORT ufix Random (uint32_t &seed, ufix range)


Member Function Documentation

EXPORT fix Fix::Add fix  a,
fix  b
[static]
 

Add two fixed-point numbers. Produces saturated result on overflow.

When the addition of two numbers is know not to cause overflow, or when this doesn't matter, normal integer addition (+) can be used instead...

    fix a;
    fix b;
    fix sum = a+b;

Parameters:
a Augend
b Addend
Returns:
a+b.
If a+b>0x7FFF.FFFF then 0x7FFF.FFFF is returned.
If a+b<-0x8000.0000 then -0x8000.0000 is returned.

Definition at line 99 of file fix.cpp.

EXPORT fix Fix::Sub fix  a,
fix  b
[static]
 

Subtract two fixed-point numbers. Produces saturated result on overflow.

When the subtraction of two numbers is know not to cause overflow, or when this doesn't matter, normal integer subtraction (-) can be used instead...

    fix a;
    fix b;
    fix difference = a-b;

Parameters:
a Minuend
b Subtrahend
Returns:
a-b.
If a-b>0x7FFF.FFFF then 0x7FFF.FFFF is returned.
If a-b<-0x8000.0000 then -0x8000.0000 is returned.

Definition at line 108 of file fix.cpp.

EXPORT fix Fix::Mul fix  a,
fix  b
[static]
 

Multiply two fixed-point numbers. Produces saturated result on overflow.

To multiply a fixed point number by an integer, normal integer multiplication (*) may be used...

    fix a;
    fix twoTimes = a*2;
This does not detect overflow.

Parameters:
a Multiplicand
b Multiplier
Returns:
a*b.
If a*b>0x7FFF.FFFF then 0x7FFF.FFFF is returned.
If a*b<-0x8000.0000 then -0x8000.0000 is returned.
See also:
MulNS()

Definition at line 117 of file fix.cpp.

EXPORT fix Fix::MulNS fix  a,
fix  b
[static]
 

Multiply two fixed-point numbers. This is a Non-Saturating (and faster) version of Mul(). On overflow the result is undefined.

To multiply a fixed point number by an integer, normal integer multiplication (*) may be used...

    fix a;
    fix twoTimes = a*2;

Parameters:
a Multiplicand
b Multiplier
Returns:
a*b.
If a*b>0x7FFF.FFFF or a*b<-0x8000.0000 then the returned result is undefined.

Definition at line 183 of file fix.cpp.

fix Fix::Div fix  a,
fix  b
[static]
 

Divide two fixed-point numbers. Produces saturated result on overflow. Division by zero is treated as division by a very small number and produces a saturated result accordingly.

To divide a fixed point number by an integer, normal integer division (/) may be used...

    fix a;
    fix half = a/2;
This does not error conditions.

Parameters:
a Dividend
b Divisor
Returns:
a/b.
If a/b>0x7FFF.FFFF then 0x7FFF.FFFF is returned.
If a/b<-0x8000.0000 then -0x8000.0000 is returned.
If b==0 and a>=0 then 0x7FFF.FFFF is returned.
If b==0 and a<0 then -0x8000.0000 is returned.

Definition at line 204 of file fix.cpp.

EXPORT fix Fix::Sqrt ufix  a  )  [static]
 

Calculate the square root of a fixed-point number.

Parameters:
a Unsigned fixed point number.
Returns:
a^0.5.

Definition at line 379 of file fix.cpp.

EXPORT fix Fix::Log2 ufix  a  )  [static]
 

Calculate the logarithm to base 2 of a fixed-point number . Accuracy is +/-8.40e-6 (+/-0.55 lsb).

Parameters:
a Unsigned fixed point number.
Returns:
log2(a).
If a==0 then -0x8000.0000 is returned

Definition at line 441 of file fix.cpp.

EXPORT ufix Fix::Exp2 fix  a  )  [static]
 

Raise 2 to-the-power of a fixed-point number, (2^a). Accuracy is +/-1.14e-5 (+/-0.75 lsb).

Parameters:
a Fixed point number.
Returns:
2^a.
If 2^a>0xFFFF.FFFF then 0xFFFF.FFFF is returned.

Definition at line 490 of file fix.cpp.

EXPORT fix Fix::Sin fixangle  angle  )  [static]
 

Calculate the Sine of an angle. Accuracy is +/-8.55e-6 (+/-0.56 lsb).

Parameters:
angle The angle.
Returns:
The Sine of angle.

Definition at line 623 of file fix.cpp.

EXPORT fix Fix::Cos fixangle  angle  )  [static]
 

Calculate the Cosine of an angle. Accuracy is +/-8.55e-6 (+/-0.56 lsb).

Parameters:
angle The angle.
Returns:
The Cosine of angle.

Definition at line 617 of file fix.cpp.

EXPORT fix Fix::Tan fixangle  angle  )  [static]
 

Calculate the Tangent of an angle. Accuracy is +/-1.01e-5 (+/-0.66 lsb).

Parameters:
angle The angle.
Returns:
The Tangent of angle.
If Tan(angle)>0x7FFF.FFFF then 0x7FFF.FFFF is returned.
If Tan(angle)<-0x8000.0000 then -0x8000.0000 is returned.

Definition at line 653 of file fix.cpp.

EXPORT fixangle Fix::ASin fix  value  )  [static]
 

Calculate the Arc-Sine of a value. Accuracy is +/-8.55e-6 (+/-0.56 lsb).

Parameters:
value The value. Should be in the range -1.0 to 1.0 (-0x10000 to 0x10000).
Returns:
The Arc-Sine of value.
If value<-1.0 then -0.25 (-0x4000) is returned.
If value>1.0 then 0.25 (0x4000) is returned.

Definition at line 836 of file fix.cpp.

EXPORT fixangle Fix::ACos fix  value  )  [static]
 

Calculate the Arc-Cosine of a value. Accuracy is +/-8.55e-6 (+/-0.56 lsb).

Parameters:
value The value. Should be in the range -1.0 to 1.0 (-0x10000 to 0x10000).
Returns:
The Arc-Cosine of value.
If value<-1.0 then 0.5 (0x8000) is returned.
If value>1.0 then 0.0 (0x0000) is returned.

Definition at line 826 of file fix.cpp.

EXPORT fixangle Fix::ATan fix  value  )  [static]
 

Calculate the Arc-Tangent of a value. Accuracy is +/-9.00e-6 (+/-0.59 lsb).

Parameters:
value The value.
Returns:
The Arc-Tangent of value.

Definition at line 919 of file fix.cpp.

EXPORT fix Fix::Random uint32_t seed  )  [static]
 

Generate a psuedo-random number.

Parameters:
seed A reference to the seed value. This will be updated after each call to this function.
Returns:
A pseudo-random number
Since:
2005-02-26

Definition at line 958 of file fix.cpp.

EXPORT ufix Fix::Random uint32_t seed,
ufix  range
[static]
 

Generate a psuedo-random number.

Parameters:
seed A reference to the seed value. This will be updated after each call to this function.
range The range for the generated numbers.
Returns:
A pseudo-random number less than the value of range
Since:
2005-02-26

Definition at line 964 of file fix.cpp.


The documentation for this class was generated from the following files:
Generated by  doxygen 1.4.4