|
Mac OS 9
|
Fixed Math Interfaces. More...
#include <MacTypes.h>Go to the source code of this file.
Macros | |
| #define | fixed1 ((Fixed)0x00010000L) |
| #define | fract1 ((Fract)0x40000000L) |
| #define | positiveInfinity ((long)0x7FFFFFFFL) |
| #define | negativeInfinity ((long)0x80000000L) |
Functions | |
| Fixed | FixRatio (short numer, short denom) |
| Fixed | FixMul (Fixed a, Fixed b) |
| short | FixRound (Fixed x) |
| Fract | Fix2Frac (Fixed x) |
| long | Fix2Long (Fixed x) |
| Fixed | Long2Fix (long x) |
| Fixed | Frac2Fix (Fract x) |
| Fract | FracMul (Fract x, Fract y) |
| Fixed | FixDiv (Fixed x, Fixed y) |
| Fract | FracDiv (Fract x, Fract y) |
| Fract | FracSqrt (Fract x) |
| Fract | FracSin (Fixed x) |
| Fract | FracCos (Fixed x) |
| Fixed | FixATan2 (long x, long y) |
| double | Frac2X (Fract x) |
| Convert a Fract to an Extended data type. More... | |
| double | Fix2X (Fixed x) |
| Convert a Fixed to an Extended data type. More... | |
| Fixed | X2Fix (double x) |
| Convert an Extended to a Fixed data type. More... | |
| Fract | X2Frac (double x) |
| Convert an Extended to a Fract data type. More... | |
| short | WideCompare (const wide *target, const wide *source) |
| wide * | WideAdd (wide *target, const wide *source) |
| wide * | WideSubtract (wide *target, const wide *source) |
| wide * | WideNegate (wide *target) |
| wide * | WideShift (wide *target, long shift) |
| unsigned long | WideSquareRoot (const wide *source) |
| wide * | WideMultiply (long multiplicand, long multiplier, wide *target) |
| long | WideDivide (const wide *dividend, long divisor, long *remainder) |
| wide * | WideWideDivide (wide *dividend, long divisor, long *remainder) |
| wide * | WideBitShift (wide *src, long shift) |
Fixed Math Interfaces.
For bug reports, consult the following page on the World Wide Web:
http://developer.apple.com/bugreporter/
| Fract Fix2Frac | ( | Fixed | x | ) |
\brief Convert a Fixed to a Fract data type <pre>Fix2Frac returns its Fixed argument, converted into a Fract data type.
argis a 32-bit Fixed value.
a 32-bit Fract value, equivalent to arg to the best precision possible for the data type.
| long Fix2Long | ( | Fixed | x | ) |
\brief Convert a Fixed to a long data type <pre>Fix2Long returns its Fixed argument, converted into a long data type.
argis a 32-bit Fixed value.
a 32-bit long value, equivalent to arg to the best precision possible for the data type.
| double Fix2X | ( | Fixed | x | ) |
Convert a Fixed to an Extended data type.
Fix2X returns its Fixed argument, converted into an Extended data type. argis a 32-bit Fixed value.
a 64-bit double value, equivalent to arg.
| Fixed FixATan2 | ( | long | x, |
| long | y | ||
| ) |
\brief Extract arctangent of the quotient of two 32-bit values <pre>FixATan2 returns the arctangent quotient of opA / opB in radians.
opAand... opBare two 32-bit values. Both should be the same data type; either long, Fixed, or Fract.
a 32-bit Fixed value; the arctangent of opA / opB, expressed in radians.
\brief Divide one 32-bit quantity by another \param opA dividend
| opB | divisor FixDiv returns the quotient of opA / opB. opAand... opBare two 32-bit values, formatted as any of the data types long, Fixed, or Fract. |
a 32-bit value whose format depends on that of the input parameters: opA opB returned Fixed/Fixed=Fixed long/long=Fixed Fract/Fract=Fixed long/Fixed=long Fract/Fixed=Fract
Division by 0 yields 0x7FFFFFFF if opA is positive or 0 and 0x80000000 if opA is negative. Division overflow yields 0x7FFFFFFF for positive results and 0x80000000 for negative results.
\brief Get fixed-point product of two integers \param a integers to . .
| b | . . . multiply FixMul performs fixed-point multiplication on two Fixed values, returning the signed product (MOD 65536) as a 32-bit Fixed data type. Use this to format the result as a Fixed data type, in case you need that type for subsequent operations. aand . . . bare Fixed values, in the range -32769 to 32767. xxxx xxxx is 1- (1/65536) |
a 32-bit Fixed value. The high 16 bits are the integer portion; the low word is always 0.
| Fixed FixRatio | ( | short | numer, |
| short | denom | ||
| ) |
FixRatio, FixMul, and FixRound were previously in ToolUtils.h
\brief Get fixed-point quotient of two integers <pre>FixRatio performs fixed-point division on two integers, returning the
quotient as a 32-bit Fixed data type. numerand . . . denomare 16-bit signed integers, in the range -32767 to 32767
a 32-bit Fixed value. The high 16 bits are the integer portion; the low word is the fractional portion.
This function will happily divide by 0; if denom is 0, this returns 0x7FFFFFFF when numer is positive or 0x8000001 when numer is negative. This is handy for calculating the spacing needed for drawing justified text (see SpaceExtra ).
| short FixRound | ( | Fixed | x | ) |
\brief Get nearest short integer to a fixed-point value <pre>FixRound rounds a positive fixed-point number, returning the value of the
nearest short integer. fixedNum is a 4-byte fixed-point value.The function rounds correctly for positive values only. See Notes, below
a 16-bit signed integer; the nearest integer to fixedNum . If the fractional part of fixedNum is .5, the return value is rounded up to the next higher integer.
To round a negative fixed-point number correctly (i.e., a larger fraction being more negative), you should first negate fixedNum , call FixRound , then negate the returned integer; e.g.: FixedunRounded; shortrounded; if (unRounded < 0 ) rounded = - FixRound ( -unRounded ); else rounded = FixRound ( unRounded );
| Fixed Frac2Fix | ( | Fract | x | ) |
\brief Convert a Fract to a Fixed data type <pre>Frac2Fix returns its Fract argument, converted into a Fixed data type.
argis a 32-bit Fract value.
a 32-bit Fixed value, equivalent to arg to the best precision possible for the data type.
| double Frac2X | ( | Fract | x | ) |
Convert a Fract to an Extended data type.
Frac2X, Fix2X, X2Fix, and X2Frac translate to and from the floating point type "extended" (that's what the X is for). On the original Mac this was 80-bits and the functions could be accessed via A-Traps. When the 68881 co-processor was added, it used 96-bit floating point types, so the A-Traps could not be used. When PowerPC was added, it used 64-bit floating point types, so yet another prototype was added.
Frac2X returns its Fract argument, converted into an Extended data type. argis a 32-bit Fract value.
a 64-bit double value, equivalent to arg to the best precision possible for the data type.
| Fract FracCos | ( | Fixed | x | ) |
\brief Extract cosine of a Fixed, returning a Fract <pre>FracCos returns the cosine of its radian argument.
argis a 32-bit Fixed data type, expressed in radians.
a 32-bit Fract value, the cosine of arg.
| Fract FracDiv | ( | Fract | x, |
| Fract | y | ||
| ) |
\brief Divide one 32-bit quantity by another \param opA dividend
| opB | divisor FracDiv returns the quotient of fracA / fracB. opAand... opBare two 32-bit values, formatted as any of the data types long, Fixed, or Fract. |
a 32-bit value, whose format depends on that of the input parameters: opA opB returned Fract/Fract=Fract long/long=Fract Fixed/Fixed=Fract long/Fract=long Fixed/Fract=Fixed
Division by 0 yields 0x7FFFFFFF if opA is positive or 0 and 0x80000000 if opA is negative. Division overflow yields 0x7FFFFFFF for positive results and 0x8000000 for negative results.
| Fract FracMul | ( | Fract | x, |
| Fract | y | ||
| ) |
\brief Multiply Fract by Fract, long, or Fixed \param opA multiplicand
| opB | multiplier FracMul returns the product of opA * opB. opAand... opBare two 32-bit values. At least one of them should be formatted as a Fract data type. |
a 32-bit value, whose format depends on that of the input parameters: opA opB returned Fract*Fract=Fract long*Fract=long Fract*long=long Fixed*Fract=Fixed Fract*Fixed=Fixed
| Fract FracSin | ( | Fixed | x | ) |
\brief Extract sine of a Fixed, returning a Fract <pre>FracSin returns the sine of its radian argument.
argis a 32-bit Fixed data type, expressed in radians.
a 32-bit Fract value, the sine of arg.
| Fract FracSqrt | ( | Fract | x | ) |
\brief Extract square root of a Fract, returning a Fract \param arg treated as an unsigned Fract, 0...4-(2^-30); <pre>FracSqrt returns the square root of its positive, fractional argument.
argis a 32-bit unsigned Fract data type.
a 32-bit Fract value, the square root of arg.
| Fixed Long2Fix | ( | long | x | ) |
\brief Convert a long to a Fixed data type <pre>Long2Fix returns its long integer argument, converted into a Fixed data
type. argis a 32-bit long value.
a 32-bit Fixed value, equivalent to arg to the best precision possible for the data type.
TARGET_CPU_68K QuickTime 3.0 makes these Wide routines available on other platforms WideCompare()
| long WideDivide | ( | const wide * | dividend, |
| long | divisor, | ||
| long * | remainder | ||
| ) |
returns the quotient WideDivide()
| unsigned long WideSquareRoot | ( | const wide * | source | ) |
quotient replaces dividend WideWideDivide()
| Fixed X2Fix | ( | double | x | ) |
Convert an Extended to a Fixed data type.
X2Fix returns its Extended argument, converted into a Fixed data type. argis an 80-bit or 96-bit Extended value.
a 32-bit Fixed value, equivalent to arg to the best precision possible for the data type.
| Fract X2Frac | ( | double | x | ) |
Convert an Extended to a Fract data type.
X2Frac returns its Extended argument, converted into a Fract data type. argis an 80-bit or 96-bit Extended value.
a 32-bit Fract value, equivalent to arg to the best precision possible for the data type.