Framework | CoreServices/CoreServices.h |
Declared in | FixMath.h IOMacOSTypes.h Math64.h ToolUtils.h fenv.h fp.h pyport.h syslog.h |
Important: This is a preliminary document. Although it has been reviewed for technical accuracy, it is not final. Apple Computer is supplying this information to help you plan for the adoption of the technologies and programming interfaces described herein. This information is subject to change, and software implemented according to this document should be tested with final operating system software and final documentation. For information about updates to this and other developer documentation, you can check the ADC Reference Library Revision List. To receive notification of documentation updates, you can sign up for ADC's free Online Program and receive the weekly Apple Developer Connection News email newsletter. (See http://developer.apple.com/membership for more details about the Online Program.)
You can use the Mathematical and Logical Utilities to perform mathematical and logical operations in Mac OS X programming. This document describes functions you can use to:
Perform low-level logical manipulation of bits and bytes when using a compiler that does not directly support such manipulations.
Save disk space by using simple compression and decompression routines.
Obtain a pseudorandom number.
Perform mathematical operations with two fixed-point data types supported directly by the Operating System.
Convert numeric variables of different types.
With the exception of the mathematical operations and conversions, these utilities are intended for programmers who occasionally need to access some of these features and do not require that the algorithms used to implement them be sophisticated. For example, if you are developing an advanced mathematical application, the pseudorandom number generator built into Mac OS might be too simplistic to fit your needs. Similarly, if you wish to access individual bits of memory in a time-critical loop, these routines are probably too slow to be practical.
Carbon supports the Mathematical and Logical Utilities, with the exception of those functions that are 68K-specific. However there are several important differences between the implementation of the Mathematical and Logical Utilities in Mac OS 9 and its implementation in Mac OS X.
The implementation in Carbon on Mac OS X of many floating-point functions defined in fp.h
is not as accurate as the implementation of those functions in MathLib on Mac OS 8 and 9 (as accessed either directly or through CarbonLib). There are a number of reasons for this difference, including the different expectations of Mac OS 9 and UNIX floating-point clients, compiler limitations, and the need in for an implementation that’s independent of assumptions about the size and layout of floating-point data types.
Functions which take parameters or return values of type long double are not exported by the Core Services framework on Mac OS X. Instead, these functions have been replaced with macros that map to the corresponding double-typed functions. While these functions are exported by CarbonLib, CFM applications calling these functions on Mac OS X should note that the implementations of the long double functions on Mac OS X actually have only double precision, with the following four exceptions: num2decl
, dec2numl
, x80told
, and ldtox80
.
acos
acosh
annuity
asin
asinh
atan
atan2
atanh
ceil
compound
copysign
cos
cosh
dec2f
dec2l
dec2num
dec2s
dec2str
dtox80
erf
erfc
exp
exp2
expm1
fabs
fdim
floor
fmax
fmin
fmod
fpclassify
frexp
gamma
hypot
isfinite
isnan
isnormal
ldexp
lgamma
log
log10
log1p
log2
logb
modf
modff
nan
nanf
nearbyint
nextafterd
nextafterf
num2dec
pi
pow
randomx
relation
remainder
remquo
rint
rinttol
round
roundtol
S32Set
S64Absolute
S64Add
S64And
S64BitwiseAnd
S64BitwiseEor
S64BitwiseNot
S64BitwiseOr
S64Compare
S64Div
S64Divide
S64Eor
S64Max
S64Min
S64Multiply
S64Negate
S64Not
S64Or
S64Set
S64SetU
S64ShiftLeft
S64ShiftRight
S64Subtract
scalb
signbit
sin
sinh
SInt64ToUInt64
sqrt
str2dec
tan
tanh
trunc
U32SetU
U64Add
U64And
U64BitwiseAnd
U64BitwiseEor
U64BitwiseNot
U64BitwiseOr
U64Compare
U64Div
U64Divide
U64Eor
U64Max
U64Multiply
U64Not
U64Or
U64Set
U64SetU
U64ShiftLeft
U64ShiftRight
U64Subtract
UInt64ToSInt64
WideAdd
WideBitShift
WideCompare
WideDivide
WideMultiply
WideNegate
WideShift
WideSquareRoot
WideSubtract
WideWideDivide
x80tod
double_t acos ( double_t x );
fp.h
double_t acosh ( double_t x );
fp.h
double annuity ( double rate, double periods );
fp.h
double_t asin ( double_t x );
fp.h
double_t asinh ( double_t x );
fp.h
double_t atan ( double_t x );
fp.h
double_t atan2 ( double_t y, double_t x );
fp.h
double_t atanh ( double_t x );
fp.h
Performs the AND
logical operation on two long words.
long BitAnd ( long value1, long value2 );
A long word.
A long word.
A long word that is the result of the AND
operation on the long words passed as arguments. Each bit in the returned value is set if and only if the corresponding bit is set in both value1
and value2
.
ToolUtils.h
Clears a particular bit (to a value of 0).
void BitClr ( void *bytePtr, long bitNum );
A pointer to a byte in memory.
The bit to be cleared, specified as a positive offset from the high-order bit of the byte pointed to by the bytePtr
parameter. The bit being cleared need not be in the same byte pointed to by bytePtr
.
The bit numbering scheme used by the BitClr
function is the opposite of the MC680x0 numbering. To convert an MC680x0 bit number to the format required by the BitClr
function, subtract the MC680x0 bit number from the highest bit number.
ToolUtils.h
Performs the NOT
logical operation on a long word.
long BitNot ( long value );
A long word.
A long word that is the result of the NOT
operation on the long word passed in as an argument. Each bit in the returned value is set if and only if the corresponding bit is not set in value
.
ToolUtils.h
Performs the OR
logical operation on two long words.
long BitOr ( long value1, long value2 );
A long word.
A long word.
A long word that is the result of the OR
operation on the long words passed as arguments. Each bit in the returned value is set if and only if the corresponding bit is set in value1
or value2
, or in both value1
and value2
.
ToolUtils.h
Sets a particular bit (to a value of 1).
void BitSet ( void *bytePtr, long bitNum );
A pointer to a byte in memory.
The bit to be set, specified as a positive offset from the high-order bit of the byte pointed to by the bytePtr
parameter. The bit being set need not be in the byte pointed to by bytePtr
.
The bit numbering scheme used by the BitSet
function is the opposite of the MC680x0 numbering. To convert an MC680x0 bit number to the format required by the BitSet
function, subtract the MC680x0 bit number from the highest bit number.
ToolUtils.h
Shifts bits in a long word.
long BitShift ( long value, short count );
A long word.
The number of bits to shift. If this number is positive, BitShift
shifts this many positions to the left; if this number is negative, BitShift
shifts this many positions to the right. The value in this parameter is converted to the result of MOD
32.
A long word that is the result of shifting the bits in the long word passed in as an argument. The shift’s direction and extent are determined by the count
parameter. Zeroes are shifted into empty positions regardless of the direction of the shift.
ToolUtils.h
Determines whether a given bit is set.
Boolean BitTst ( const void *bytePtr, long bitNum );
A pointer to a byte in memory.
The bit to be tested, specified as a positive offset from the high-order bit of the byte pointed to by the bytePtr
parameter. The bit being tested need not be in the byte pointed to by bytePtr
.
TRUE
if the specified bit is set (that is, has a value of 1) and FALSE
if the bit is cleared (that is, has a value of 0).
The bit numbering scheme used by the BitTst
function is the opposite of the MC680x0 numbering. To convert an MC680x0 bit number to the format required by the BitTst
function, subtract the MC680x0 bit number from the highest bit number.
ToolUtils.h
Performs the XOR
logical operation on two long words.
long BitXor ( long value1, long value2 );
A long word.
A long word.
A long word that is the result of the XOR
operation on the long words passed in as arguments. Each bit in the returned value is set if and only if the corresponding bit is set in either value1
or value2
, but not in both value1
and value2
.
ToolUtils.h
double_t ceil ( double_t x );
fp.h
double compound ( double rate, double periods );
fp.h
double_t copysign ( double_t x, double_t y );
fp.h
double_t cos ( double_t x );
fp.h
double_t cosh ( double_t x );
fp.h
float dec2f ( const decimal *d );
fp.h
long dec2l ( const decimal *d );
fp.h
double_t dec2num ( const decimal *d );
fp.h
short dec2s ( const decimal *d );
fp.h
void dec2str ( const decform *f, const decimal *d, char *s );
fp.h
void dtox80 ( const double *x, extended80 *x80 );
fp.h
double_t erf ( double_t x );
fp.h
double_t erfc ( double_t x );
fp.h
double_t exp ( double_t x );
fp.h
double_t exp2 ( double_t x );
fp.h
double_t expm1 ( double_t x );
fp.h
double_t fabs ( double_t x );
fp.h
double_t fdim ( double_t x, double_t y );
fp.h
Converts a Fixed
number to a Fract
number.
Fract Fix2Frac ( Fixed x );
The Fixed
number to be converted to a Fract
number.
The Fract
number equivalent to the Fixed
number x
. If x
is greater than the maximum representable Fract
number, the Fix2Frac
function returns $7FFFFFFF. If x
is less than the negative number with the highest absolute value, Fix2Frac
returns $80000000.
FixMath.h
Converts a Fixed
number to a LongInt
number.
SInt32 Fix2Long ( Fixed x );
The Fixed
number to be converted to a long integer.
The long integer nearest to the Fixed
number x
. If x
is halfway between two integers (0.5), it is rounded to the integer with the higher absolute value.
FixMath.h
Converts a Fixed
number to an Extended
number.
double Fix2X ( Fixed x );
The Fixed
number to be converted to an Extended
number.
The Extended
equivalent of the Fixed
number x
.
Fix2X
does not move memory; you can call it at interrupt time.
FixMath.h
Obtains a fast approximation of the arctangent of a fraction.
Fixed FixATan2 ( SInt32 x, SInt32 y );
The numerator of the fraction whose arctangent is to be obtained. This variable can be a LongInt
, Fixed
, or Fract
number.
The denominator of the fraction whose arctangent is to be obtained. The number supplied in this variable must be of the same type as that of the number supplied in the x
parameter.
The arctangent of y/x
, in radians.
The approximation of p/4 used to compute the arctangent is the hexadecimal value 0.C910, making the approximation of p equal to 3.1416015625, while p itself equals 3.14159265.... Thus FixATan2(1, 1)
equals the equivalent of the hexadecimal value 0.C910. Despite the approximation of p, the arctangent value obtained will usually be correct to several decimal places.
FixMath.h
Divides two variables of the same type (Fixed
, Fract
, or LongInt
) or to divide a LongInt
or Fract
number by a Fixed
number.
Fixed FixDiv ( Fixed x, Fixed y );
The first operand, which can be a variable of type Fixed
or a variable of type Fract
or LongInt
.
The second operand, which can be a variable of type Fixed
or it can be a variable of the same type as the variable in parameter x
.
The quotient of the numbers in x
and y
. If the y
parameter is in the format of a Fixed
number, then the x
parameter can be in the format of a Fixed
, Fract
, or LongInt
number. If the y
parameter is in the format of a Fract
or LongInt
number, then the x
parameter must be in the same format.
The returned value is in the format of a Fixed
number if both x
and y
are both Fixed
numbers, both Fract
numbers, or both LongInt
numbers. Otherwise, the returned value is the same type as the number in the x
parameter.
Division by zero results in $8000000 if x
is negative, and $7FFFFFFF otherwise; thus the special case 0/0 yields $7FFFFFFF.
FixMath.h
Converts a Fixed
number to a float
number.
float FixedToFloat ( Fixed x );
The Fixed
number to be converted.
The float
equivalent of the Fixed
number.
This function is implemented as an inline macro.
FixMath.h
Multiplies a variable of type Fixed
with another variable of type Fixed
or with a variable of type Fract
or LongInt
.
Fixed FixMul ( Fixed a, Fixed b );
The first operand, which can be a variable of type Fixed
or a variable of type Fract
or LongInt
.
The second operand, which can be a variable of type Fixed
or a variable of type Fract
or LongInt
.
The product of the numbers in a
and b
. At least one of a
and b
should be a variable of type Fixed
.
The returned value is in the format of a LongInt
if one of a
or b
is a LongInt
. It is a Fract
number if one of a
or b
is Fract
. It is a Fixed
number if both a
and b
are Fixed
numbers.
Overflows are set to the maximum representable value with the correct sign ($80000000 for negative results and $7FFFFFFF for positive results).
FixMath.h
Obtains the Fixed
equivalent of a fraction.
Fixed FixRatio ( short numer, short denom );
The numerator of the fraction.
The denominator of the fraction.
The Fixed
equivalent of the fraction numer/denom
.
FixMath.h
Rounds a fixed-point number to the nearest integer.
short FixRound ( Fixed x );
The Fixed
number to be rounded.
The Integer
number nearest the Fixed
number x
. If the value is halfway between two integers (0.5), it is rounded up. Thus, 4.5 is rounded to 5, and –3.5 is rounded to –3.
To round a negative Fixed
number so that values halfway between two integers are rounded to the number with the higher absolute value, negate the number, round it, and then negate it again.
FixMath.h
Converts a float
number to a Fixed
number.
Fixed FloatToFixed ( float x );
The float
number to be converted.
The Fixed
equivalent of the float
number.
This function is implemented as an inline macro.
FixMath.h
Converts a float
number to a Fract
number.
Fract FloatToFract ( float x );
The float
number to be converted.
The Fract
equivalent of the float
number.
This function is implemented as an inline macro.
FixMath.h
double_t floor ( double_t x );
fp.h
double_t fmax ( double_t x, double_t y );
fp.h
double_t fmin ( double_t x, double_t y );
fp.h
double_t fmod ( double_t x, double_t y );
fp.h
long fpclassify ( float x );
A value of type float
or double
.
Returns one of the FP_ values. See FP_SNAN
.
This function is implemented as an inline macro.
fp.h
Converts a Fract
number to a Fixed
number.
Fixed Frac2Fix ( Fract x );
The Fract
number to be converted to a Fixed
number.
The Fixed
number that best approximates the Fract
number x
.
FixMath.h
Converts a Fract
number to an Extended
number.
double Frac2X ( Fract x );
The Fract
number to be converted to an Extended
number.
The Extended
equivalent of the Fract
number x
.
FixMath.h
Obtains a fast approximation of the cosine of a Fixed
number.
Fract FracCos ( Fixed x );
The Fixed
number expressed in radians, whose cosine is to be calculated.
The cosine, expressed in radians, of the Fixed
number x
.
The approximation of p/4 used to compute the cosine is the hexadecimal value 0.C910, making the approximation of p equal to 3.1416015625, while p itself equals 3.14159265.... Despite the approximation of p, the cosine value obtained is usually correct to several decimal places.
FixMath.h
Divides two variables of the same type (Fract
, Fixed
, or LongInt
) or to divide a LongInt
or Fixed
number by a Fract
number.
Fract FracDiv ( Fract x, Fract y );
The first operand, which can be a variable of type Fract
or a variable of type Fixed
or LongInt
.
The second operand, which can be a variable of type Fract
or a variable of the same type as the variable in parameter a
.
The quotient of the numbers in a
and b
. If the b
parameter is in the format of a Fract
number, then the a
parameter can be in the format of a Fract
, a Fixed
, or a LongInt
number. If the b
parameter is in the format of a Fixed
or a LongInt
number, then the a
parameter must be in the same format.
The returned value is in the format of a Fract
number if a
and b
are both Fract
numbers, both Fixed
numbers, or both LongInt
numbers. Otherwise, the returned value is in the same format as the number in the a
parameter.
Division by zero results in $8000000 if a
is negative, and $7FFFFFFF otherwise; thus the special case 0/0 yields $7FFFFFFF.
FixMath.h
Multiplies a variable of type Fract
with another variable of type Fract
or with a variable of type Fixed
or LongInt
.
Fract FracMul ( Fract x, Fract y );
The first operand, which can be a variable of type Fract
or a variable of type Fixed
or LongInt
.
The second operand, which can be a variable of type Fract
or a variable of type Fixed
or LongInt
.
The product of the numbers in a
and b
. At least one of a
or b
should be a variable of type Fract
.
The returned value is in the format of a LongInt
number if one of a
and b
is a LongInt
number. It is a Fixed
number if one of a
or b
is a Fixed
number. It is a Fract
number if both a
and b
are Fract
numbers.
Overflows are set to the maximum representable value with the correct sign ($80000000 for negative results and $7FFFFFFF for positive results).
FixMath.h
Obtains a fast approximation of the sine of a Fixed
number.
Fract FracSin ( Fixed x );
The Fixed
number expressed in radians, whose sine is to be calculated.
The sine, expressed in radians, of the Fixed
number x
.
The approximation of p/4 used to compute the sine is the hexadecimal value 0.C910, making the approximation of p equal to 3.1416015625, while p itself equals 3.14159265.... Despite the approximation of p, the sine value obtained is usually correct to several decimal places.
FixMath.h
Obtains the square root of a Fract
number.
Fract FracSqrt ( Fract x );
The Fract
number to obtain a square root of. This parameter is interpreted as being unsigned in the range 0 through 4 – 2–30, inclusive. That is, the bit of the Fract
number that ordinarily has weight -2 is instead interpreted as having weight 2.
The square root of the specified Fract
number. The result is unsigned in the range 0 through 2, inclusive.
FixMath.h
Converts a Fract
number to a float
number.
float FixedToFract ( Fract x );
The Fract
number to be converted.
The float
equivalent of the Fract
number.
This function is implemented as an inline macro.
FixMath.h
double_t frexp ( double_t x, int *exponent );
fp.h
double_t gamma ( double_t x );
fp.h
Obtains the high-order word of a long word.
SInt16 HiWord ( SInt32 x );
The long word whose high word is to be returned.
The high-order word of the long word specified by the x
parameter.
One use of this function is to obtain the integral part of a fixed-point number.
To copy a range of bytes from one memory location to another, you should ordinarily use the Memory Manager function, BlockMove
.
ToolUtils.h
double_t hypot ( double_t x, double_t y );
pyport.h
long isfinite ( float x );
A value of type float
or double
.
Returns a non-zero value only if the argument is finite.
This function is implemented as an inline macro.
fp.h
long isnan ( float x );
A value of type float
or double
.
Returns a non-zero value only if the argument is not a number (NaN).
This function is implemented as an inline macro.
fp.h
long isnormal ( float x );
A value of type float
or double
.
Returns a non-zero value only if the argument is normalized.
This function is implemented as an inline macro.
fp.h
double_t ldexp ( double_t x, int n );
fp.h
double_t lgamma ( double_t x );
fp.h
double_t log ( double_t x );
syslog.h
double_t log10 ( double_t x );
fp.h
double_t log1p ( double_t x );
fp.h
double_t log2 ( double_t x );
fp.h
double_t logb ( double_t x );
fp.h
Converts a LongInt
number to a Fixed
number.
Fixed Long2Fix ( SInt32 x );
The long integer to be converted to a Fixed
number.
The Fixed
number equivalent to the long integer x
. If x
is greater than the maximum representable fixed-point number, the Long2Fix
function returns $7FFFFFFF. If x
is less than the negative number with the highest absolute value, Long2Fix
returns $80000000.
FixMath.h
Obtains the low-order word of a long word.
SInt16 LoWord ( SInt32 x );
The long word whose low word is to be returned.
The low-order word of the long word specified by the x
parameter.
One use of this function is to obtain the fractional part of a fixed-point number.
To copy a range of bytes from one memory location to another, you should ordinarily use the Memory Manager function, BlockMove
.
ToolUtils.h
double_t modf ( double_t x, double_t *iptr );
fp.h
float modff ( float x, float *iptrf );
fp.h
double nan ( const char *tagp );
fp.h
float nanf ( const char *tagp );
fp.h
double_t nearbyint ( double_t x );
fp.h
double nextafterd ( double x, double y );
fp.h
float nextafterf ( float x, float y );
fp.h
void num2dec ( const decform *f, double_t x, decimal *d );
fp.h
pi ();
fp.h
double_t pow ( double_t x, double_t y );
fp.h
double_t randomx ( double_t *x );
fp.h
relop relation ( double_t x, double_t y );
fp.h
double_t remainder ( double_t x, double_t y );
fp.h
double_t remquo ( double_t x, double_t y, int *quo );
fp.h
double_t rint ( double_t x );
fp.h
long rinttol ( double_t x );
fp.h
double_t round ( double_t x );
fp.h
long roundtol ( double_t round );
fp.h
SInt32 S32Set ( SInt64 value );
Math64.h
SInt64 S64Absolute ( SInt64 value );
Math64.h
SInt64 S64Add ( SInt64 left, SInt64 right );
Math64.h
Boolean S64And ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64BitwiseAnd ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64BitwiseEor ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64BitwiseNot ( SInt64 value );
Math64.h
SInt64 S64BitwiseOr ( SInt64 left, SInt64 right );
Math64.h
SInt32 S64Compare ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64Div ( SInt64 dividend, SInt64 divisor );
Math64.h
SInt64 S64Divide ( SInt64 dividend, SInt64 divisor, SInt64 *remainder );
Math64.h
Boolean S64Eor ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64Max ( void );
Math64.h
SInt64 S64Min ( void );
Math64.h
SInt64 S64Multiply ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64Negate ( SInt64 value );
Math64.h
Boolean S64Not ( SInt64 value );
Math64.h
Boolean S64Or ( SInt64 left, SInt64 right );
Math64.h
SInt64 S64Set ( SInt32 value );
Math64.h
SInt64 S64SetU ( UInt32 value );
Math64.h
SInt64 S64ShiftLeft ( SInt64 value, UInt32 shift );
Math64.h
SInt64 S64ShiftRight ( SInt64 value, UInt32 shift );
Math64.h
SInt64 S64Subtract ( SInt64 left, SInt64 right );
Math64.h
double_t scalb ( double_t x, _scalb_n_type n );
fp.h
long signbit ( float x );
A value of type float
or double
, NaN, infinity, or zero.
Returns a non-zero value only if the sign of the argument is negative.
This function is implemented as an inline macro.
fp.h
double_t sin ( double_t x );
fp.h
double_t sinh ( double_t x );
fp.h
UInt64 SInt64ToUInt64 ( SInt64 value );
Math64.h
double_t sqrt ( double_t x );
fp.h
void str2dec ( const char *s, short *ix, decimal *d, short *vp );
fp.h
double_t tan ( double_t x );
fp.h
double_t tanh ( double_t x );
fp.h
_trunc_return_type trunc ( double_t x );
fp.h
UInt32 U32SetU ( UInt64 value );
Math64.h
UInt64 U64Add ( UInt64 left, UInt64 right );
Math64.h
Boolean U64And ( UInt64 left, UInt64 right );
Math64.h
UInt64 U64BitwiseAnd ( UInt64 left, UInt64 right );
Math64.h
UInt64 U64BitwiseEor ( UInt64 left, UInt64 right );
Math64.h
UInt64 U64BitwiseNot ( UInt64 value );
Math64.h
UInt64 U64BitwiseOr ( UInt64 left, UInt64 right );
Math64.h
SInt32 U64Compare ( UInt64 left, UInt64 right );
Math64.h
Under evaluation
UInt64 U64Div ( UInt64 dividend, UInt64 divisor );
Math64.h
UInt64 U64Divide ( UInt64 dividend, UInt64 divisor, UInt64 *remainder );
Math64.h
Boolean U64Eor ( UInt64 left, UInt64 right );
Math64.h
UInt64 U64Max ( void );
Math64.h
UInt64 U64Multiply ( UInt64 left, UInt64 right );
Math64.h
Boolean U64Not ( UInt64 value );
Math64.h
Boolean U64Or ( UInt64 left, UInt64 right );
Math64.h
UInt64 U64Set ( SInt32 value );
Math64.h
UInt64 U64SetU ( UInt32 value );
Math64.h
UInt64 U64ShiftLeft ( UInt64 value, UInt32 shift );
Math64.h
UInt64 U64ShiftRight ( UInt64 value, UInt32 shift );
Math64.h
UInt64 U64Subtract ( UInt64 left, UInt64 right );
Math64.h
SInt64 UInt64ToSInt64 ( UInt64 value );
Math64.h
wide * WideAdd ( wide *target, const wide *source );
FixMath.h
wide * WideBitShift ( wide *target, SInt32 shift );
FixMath.h
short WideCompare ( const wide *target, const wide *source );
FixMath.h
SInt32 WideDivide ( const wide *dividend, SInt32 divisor, SInt32 *remainder );
FixMath.h
wide * WideMultiply ( SInt32 multiplicand, SInt32 multiplier, wide *target );
FixMath.h
wide * WideNegate ( wide *target );
FixMath.h
wide * WideShift ( wide *target, SInt32 shift );
FixMath.h
UInt32 WideSquareRoot ( const wide *source );
FixMath.h
wide * WideSubtract ( wide *target, const wide *source );
FixMath.h
wide * WideWideDivide ( wide *dividend, SInt32 divisor, SInt32 *remainder );
FixMath.h
Converts an Extended
number to a Fixed
number.
Fixed X2Fix ( double x );
The Extended
number to be converted to a Fixed
number.
The best Fixed
approximation of the Extended
number x
. If x
is greater than the maximum representable Fixed
number, the X2Fix
function returns $7FFFFFFF. If x
is less than the negative number with the highest absolute value, X2Fix
returns $80000000.
FixMath.h
Converts an Extended
number to a Fract
number.
Fract X2Frac ( double x );
The Extended
number to be converted to a Fract
number.
The best Fract
approximation of the Extended
number x
. If x
is greater than the maximum representable Fract
number, the X2Frac
function returns $7FFFFFFF. If x
is less than the negative number with the highest absolute value, X2Frac
returns $80000000.
FixMath.h
double x80tod ( const extended80 *x80 );
fp.h
struct decform { char style; char unused; short digits; }; typedef struct decform decform;
style
unused
digits
fp.h
struct decimal { char sgn char unused short exp struct { unsigned char length; unsigned char text[36]; unsigned char pad; } sig; }; typedef struct decimal decimal;
sgn
unused
exp
length
text
pad
fp.h
typedef double double_t;
fp.h
typedef SInt32 fenv_t;
fenv.h
typedef SInt32 fexcept_t;
fenv.h
Defines a data type for fixed-point decimal numbers.
typedef SInt32 Fixed;
This data type uses a 16-bit signed integer and a 16-bit fraction to represent fixed-point decimal numbers in the interval:
For example, the number 1.5 would be represented as 0x00018000
, and the number -1.3 would be represented as 0xFFFEB334
. To convert numbers between Fixed
and float
, you can use the functions FixedToFloat
and FloatToFixed
.
IOMacOSTypes.h
Defines a high-precision data type for fixed-point decimal numbers.
typedef SInt32 Fract;
This data type uses a 2-bit signed integer and a 30-bit fraction to represent fixed-point decimal numbers in the interval
with higher precision than the Fixed
data type. For example, the number 1.5 would be represented as 0x60000000
, and the number -1.3 would be represented as 0xACCCCCCD
. To convert numbers between Fract
and float
, you can use the functions FractToFloat
and FloatToFract
.
IOMacOSTypes.h
typedef float float_t;
fp.h
typedef short relop;
fp.h
typedef int _scalb_n_type;
typedef double_t _trunc_return_type;
enum { DECSTROUTLEN = 80 };
Definitions of floating-point exception macros.
enum { FE_INEXACT = 0x02000000, FE_DIVBYZERO = 0x04000000, FE_UNDERFLOW = 0x08000000, FE_OVERFLOW = 0x10000000, FE_INVALID = 0x20000000, FE_ALL_EXCEPT = 0x3E000000 };
FE_INEXACT
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_DIVBYZERO
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_UNDERFLOW
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_OVERFLOW
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_INVALID
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_ALL_EXCEPT
Available in Mac OS X v10.1 through Mac OS X v10.1.
Declared in fenv.h
.
enum { FE_LDBLPREC = 0, FE_DBLPREC = 1, FE_FLTPREC = 2 };
Definitions of rounding direction macros.
enum { FE_TONEAREST = 0x00000000, FE_TOWARDZERO = 0x00000001, FE_UPWARD = 0x00000002, FE_DOWNWARD = 0x00000003 };
FE_TONEAREST
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_TOWARDZERO
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_UPWARD
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
FE_DOWNWARD
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fenv.h
.
enum { fixed1 = 0x00010000, fract1 = 0x40000000, positiveInfinity = 0x7FFFFFFF, negativeInfinity = 0x80000000 };
enum { FP_SNAN = 0, FP_QNAN = 1, FP_INFINITE = 2, FP_ZERO = 3, FP_NORMAL = 4, FP_SUBNORMAL = 5 };
FP_SNAN
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fp.h
.
FP_QNAN
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fp.h
.
FP_INFINITE
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fp.h
.
FP_ZERO
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fp.h
.
FP_NORMAL
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fp.h
.
FP_SUBNORMAL
Available in Mac OS X v10.0 through Mac OS X v10.1.
Declared in fp.h
.
typedef short relop; enum { GREATERTHAN = 0, LESSTHAN = 1, EQUALTO = 2, UNORDERED = 3 };
GREATERTHAN
Available in Mac OS X v10.0 and later.
Declared in fp.h
.
LESSTHAN
Available in Mac OS X v10.0 and later.
Declared in fp.h
.
EQUALTO
Available in Mac OS X v10.0 and later.
Declared in fp.h
.
UNORDERED
Available in Mac OS X v10.0 and later.
Declared in fp.h
.
enum { SIGDIGLEN = 36 };
#define HUGE_VAL #define INFINITY
HUGE_VAL
Available in Mac OS X v10.0 and later.
Declared in fp.h
.
INFINITY
Available in Mac OS X v10.0 and later.
Declared in fp.h
.
© 2003, 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-11-09)