Fixed point arithmetic functions.
More...
#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.
Member Function Documentation
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...
- Parameters:
-
- 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.
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...
- Parameters:
-
- 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.
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...
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.
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...
- 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.
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...
This does not error conditions.
- Parameters:
-
- 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.
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.
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.
Raise 2 to-the-power of a fixed-point number, (2^a). Accuracy is +/-1.14e-5 (+/-0.75 lsb).
- Parameters:
-
- Returns:
- 2^a.
If 2^a>0xFFFF.FFFF then 0xFFFF.FFFF is returned.
Definition at line 490 of file fix.cpp.
Calculate the Sine of an angle. Accuracy is +/-8.55e-6 (+/-0.56 lsb).
- Parameters:
-
- Returns:
- The Sine of angle.
Definition at line 623 of file fix.cpp.
Calculate the Cosine of an angle. Accuracy is +/-8.55e-6 (+/-0.56 lsb).
- Parameters:
-
- Returns:
- The Cosine of angle.
Definition at line 617 of file fix.cpp.
Calculate the Tangent of an angle. Accuracy is +/-1.01e-5 (+/-0.66 lsb).
- Parameters:
-
- 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.
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.
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.
Calculate the Arc-Tangent of a value. Accuracy is +/-9.00e-6 (+/-0.59 lsb).
- Parameters:
-
- Returns:
- The Arc-Tangent of value.
Definition at line 919 of file fix.cpp.
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.
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: