- Inherits from:
- Object
- Conforms to:
- DComparable, DSimpleArithmetic, DTextable
- Declared in:
- DFixedPoint.h
Object
|
+---DFixedPoint
Class Description
The fixed point class implements a 'floating point number' in a long with a
fixed point. The format is ..2^3+2^2+2^1+2^0+2^(-1)+2^(-2)+2^(-3)... For
example if the point is set to 3 bits, the binary number 11011 equals to
3.375.
- Last modified:
- 12-Jun-2005 (DFixedPoint.h)
Instance Variables
- private long _value
- the value of the fixed point
- private unsigned _point
- the number of bits for the point
- Constructors
- - (DFixedPoint *) init
- Initialise to fixed point to zero with no fixed point
- Returns:
- the object
- - (DFixedPoint *) init :(unsigned) point
- Initialise to a fixed point
- Parameters:
- point - the number of bits in the point (0..DFP_MAX_POINT)
- Returns:
- the object
- - (DFixedPoint *) init :(long) value :(unsigned) point
- Initialise to a fixed point
- Parameters:
- value - the value for the fixed point
point - the number of bits in the point
- Returns:
- the object
- Member methods
- - (long) get
- Get the fixed point number
- Returns:
- the fixed point number
- - (DFixedPoint *) move :(DFixedPoint *) other
- Move an other object in this object
- Parameters:
- other - the other object
- Returns:
- this object
- - (DFixedPoint *) norm
- Normalize the fixed point number by removing trailing zero bits
- Returns:
- the object
- - (unsigned) point
- Get the point
- Returns:
- the number of bits in the point
- - (DFixedPoint *) point :(unsigned) point
- Change the precision of the current fixed point by changing the point
- Parameters:
- point - the number of bits in the point (0..DFN_MAX_POINT)
- Returns:
- the object
- - (DFixedPoint *) set :(long) value
- Set the fixed point number (using the current point)
- Parameters:
- value - the fixed point number
- Returns:
- the object
- - (DFixedPoint *) set :(long) value :(unsigned) point
- Set the fixed point number
- Parameters:
- value - the fixed point number
point - the number of bits for the point
- Returns:
- the object
- Methods on fixed point numbers
- - (DFixedPoint *) add :(DFixedPoint *) other
- Add with an other fixed point number
- Parameters:
- other - the fixed point number
- Returns:
- the object
- - (DFixedPoint *) add :(DFixedPoint *) src1 :(DFixedPoint *) src2
- Add two fixed point numbers and store the result in the object
- Parameters:
- src1 - the first fixed point number
src2 - the second fixed point number
- Returns:
- the object
- - (DFixedPoint *) div :(DFixedPoint *) other
- Divide with a fixed point number (Note: if the result of the division is zero
or has to little precision, use point: to scale up the fixed point number)
- Parameters:
- other - the divider
- Returns:
- the object
- - (DFixedPoint *) div :(DFixedPoint *) src1 :(DFixedPoint *) src2
- Divide two fixed point numbers and store the result in the object. (Note:
if the result of the division is zero or has to little precision, use point:
to scale up the fixed point number)
- Parameters:
- src1 - the fixed point number
src2 - the divider
- Returns:
- the object
- - (DFixedPoint *) mul :(DFixedPoint *) other
- Multiply with an other fixed point number
- Parameters:
- other - the fixed point number
- Returns:
- the object
- - (DFixedPoint *) mul :(DFixedPoint *) src1 :(DFixedPoint *) src2
- Multiply two fixed point numbers and store the result in the object
- Parameters:
- src1 - the first fixed point number
src2 - the second fixed point number
- Returns:
- the object
- - (DFixedPoint *) sub :(DFixedPoint *) other
- Subract with another fixed point number
- Parameters:
- other - the fixed point number
- Returns:
- the object
- - (DFixedPoint *) sub :(DFixedPoint *) src1 :(DFixedPoint *) src2
- Subract two fixed point numbers and store the result in the object
- Parameters:
- src1 - the first fixed point number
src2 - the second fixed point number
- Returns:
- the object
- Textable protocol methods
- - (DText *) toText
- Convert to a text string (decimal representation)
- Returns:
- a (new) text string with the fixed point number
- Comparable protocol methods
- - (int) compare :(DFixedPoint *) other
- Compare two fixed point numbers
- Parameters:
- other - the other fixed point number (!= nil)
- Returns:
- the comparison result (-1 = smaller, 0 = equal, 1 = bigger)
- Conversion methods
- - (double) toDouble
- Convert the fixed point number to a double
- Returns:
- the double
generated 08-Jan-2006 by ObjcDoc 3.0.0