This section contains functions and macros to perform math operations and conversions for the following types:
ODFixed | A 32-bit fixed-point value used to represent non-integer numbers in the range [-32768, 32768). The most-significant 16 bits are integral and the least-significant 16 bits are fractional. |
ODFract | A 32-bit fixed-point value used to represent non-integer numbers in the range [-2, 2). The most-significant 2 bits are integral and the least-significant 30 bits are fractional. |
ODFloat | A floating-point value. |
ODSLong | A signed 32-bit integer value. |
ODSShort | A signed 16-bit integer value. |
ODULong | An unsigned 32-bit integer value. |
ODUShort | An unsigned 16-bit integer value. |
ODWide | A 64-bit signed integer. |
The following lists the math functions and macros in alphabetic order.
This function returns the position of the first bit set in a signed long.
Signature
#include <odmath.h> ODSShort ODFirstBit (ODSLong a) |
Parameters
Returns
This function divides one fixed-point number by another fixed-point number.
Signature
#include <odmath.h> ODFixed ODFixedDivide (ODFixed a, ODFixed b) |
Parameters
Returns
This macro rounds a fixed-point number to a signed short.
Signature
#include <odmath.h> ODSShort ODFixedRound (ODFixed a) |
Parameters
Returns
This function multiplies two fixed-point numbers.
Signature
#include <odmath.h> ODFixed ODFixedMultiply (ODFixed a, ODFixed b) |
Parameters
Returns
This macro converts a fixed-point number to a floating-point number.
Signature
#include <odmath.h> ODFloat ODFixedToFloat (ODFixed a) |
Parameters
Returns
This macro converts a fixed-point number (16:16) to a fractional number (2:30).
Signature
#include <odmath.h> ODFract ODFixedToFract (ODFixed a) |
Parameters
Returns
This macro converts a floating-point number to a fixed-point number (16:16).
Signature
#include <odmath.h> ODFixed ODFloatToFixed (ODFloat a) |
Parameters
Returns
This macro converts a floating-point number to a fractional number (2:30).
Signature
#include <odmath.h> ODFract ODFloatToFract (ODFloat a) |
Parameters
Returns
This function divides one factional number by another fractional number.
Signature
#include <odmath.h> ODFract ODFractDivide (ODFract a, ODFract b) |
Parameters
Returns
This function multiplies two fractional numbers.
Signature
#include <odmath.h> ODFract ODFractMultiply (ODFract a, ODFract b) |
Parameters
Returns
This function returns the sine and cosine of a fractional number.
Signature
#include <odmath.h> ODFract ODFractSinCos (ODFixed angle, ODFract *cos) |
Parameters
Returns
This macro converts a fractional number (2:30) to a fixed-point number (16:16).
Signature
#include <odmath.h> ODFixed ODFractToFixed (ODFract a) |
Parameters
Returns
This function converts a fractional number (2:30) to a floating-point number.
Signature
#include <odmath.h> ODFloat ODFractToFloat (ODFract a) |
Parameters
Returns
This macro converts a signed short to a fixed-point number (16:16).
Signature
#include <odmath.h> ODFixed IntToODFixed (ODSShort a) |
Parameters
Returns
This function adds two wide integers.
Signature
#include <odmath.h> ODWide *ODWideAdd (ODWide *a, const ODWide *b) |
Parameters
Returns
This function compares two wide integers.
Signature
#include <odmath.h> ODSShort ODWideCompare (const ODWide *a, const ODWide *b) |
Parameters
Returns
1 | a > b |
0 | a = b |
-1 | a < b |
This function divides one wide integer by a long integer.
Signature
#include <odmath.h> DSLong ODWideDivide (const ODWide *dividend, ODSLong divisor, ODSLong *remainder) |
Parameters
Returns
This macro indicates whether a wide integer has less than 32 bits of significance.
Signature
#include <odmath.h> ODBoolean ODWideIsLong (ODWide w) |
Parameters
Returns
kODTrue | The specified wide integer has less than 32 bits of significance. |
kODFalse | The specified wide integer has at least than 32 bits of significance. |
This function multiplies two signed, long integers.
Signature
#include <odmath.h> ODWide *ODWideMultiply (ODSLong a, ODSLong b, ODWide *result) |
Parameters
Returns
This function negates a wide integer.
Signature
#include <odmath.h> ODWide *ODWideNegate |
Parameters
Returns
This function shifts a wide integer by the specified number of bits.
Signature
#include <odmath.h> ODWide *ODWideShift (ODWide *w, ODSShort bits) |
Parameters
>0 | Shifts to the right. |
<0 | Shifts to the left. |
0 | Does not shift. |
Returns
This function returns the approximate square root of a wide integer.
Signature
#include <odmath.h> ODULong ODWideSquareRoot (const ODWide *src) |
Parameters
Returns
This function subtracts two wide integers.
Signature
#include <odmath.h> ODWide *ODWideSubtract (ODWide *a, const ODWide *b) |
Parameters
Returns