Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 3 - Appendixes
Appendix E - MathLib Reference


Operations and Functions

Note
Throughout the tables that follow, in the Exceptions column, I = invalid; X = inexact; O = overflow; U = underflow; D = divide-by-zero.
Table E-6 Arithmetic operations
ComputeSyntaxValid input rangeExceptions
Sumx + y - to + I X O U -
Differencex - y - to + I X O U -
Productx * y - to + I X O U -
Quotientx / y - to + I X O U D
Square rootsqrt(x)0 to + I X - - -
Remainderremainder(x,y)
remquo(x,y,quo)
fmod(x,y)
- to + I - - - -
Table E-7 Conversions to integer type
ComputeSyntaxValid input rangeExceptions
Round in current directionrinttol(x)[75] -231to231+-1 I X - - -
Add 1/2 to magnitude and choproundtol(x)[75] -231to231+-1 I X - - -
Table E-8 Conversions to integer in floating-point type
ComputeSyntaxValid input rangeExceptions
Round in current directionrint(x) - to + - X - - -
 nearbyint(x) - to + - - - - -
Round upwardceil(x) - to + - - - - -
Round downwardfloor(x) - to + - - - - -
Add 1/2 to magnitude and chopround(x) - to + - X - - -
Round toward zerotrunc(x) - to + - - - - -
Table E-9 Conversions between binary and decimal formats
ComputeSyntaxValid input rangeExceptions
Convert decimal struct to binarydec2num(&d)decimal struct- - - - -
Convert binary to decimal structnum2dec(&f,x,&d) - to + - - - - -
Table E-10 Conversions between decimal formats
ComputeSyntaxValid input rangeExceptions
Convert decimal struct to stringdec2str(&f,&d,s)decimal struct- - - - -
Convert decimal string to structstr2dec(s,&ix,&d,&vp)Numeric string- - - - -
Table E-11 Comparison operations
ComputeSyntaxValid input rangeExceptions
Positive difference or 0fdim(x,y) - to + - X O U -
Maximum of 2 numbersfmax(x,y) - to + - - - - -
Minimum of 2 numbersfmin(x,y) - to + - - - - -
Relationship of x, yrelation(x,y) - to + - - - - -
Table E-12 Sign manipulation functions
ComputeSyntaxValid input rangeExceptions
Copy the signcopysign(x,y) - to + - - - - -
|x|fabs(x) - to + - - - - -
Table E-13 Exponential functions
ComputeSyntaxValid input rangeExceptions
ex exp(x) - to + - X O U -
2x exp2(x) - to + - X O U -
ex+-1 expm1(x) - to + - X O U -
x×2n ldexp(x,n) - to + - X O U -
 scalb(x,n) - X O U -
xy pow(x,y) - to + I X O U D
Table E-14 Logarithmic functions
ComputeSyntaxValid input rangeExceptions
Fraction and exponent fields of floating-point numberfrexp(x,&n) - to + - - - - -
ln xlog(x)0 to + I X - - D
log10x log10(x)0 to + I X - - D
ln (x + 1)log1p(x)> -1I X - - D
log2x log2(x)0 to + I X - - D
Exponent field of floating-point numberlogb(x) - to + - - - - D
Split real number into fractional part and integer partmodf(x,&y) - to + - - - - -
Table E-15 Trigonometric functions
ComputeSyntaxValid input rangeExceptions
cos xcos(x)Any finite numberI X - - -
sin xsin(x)Any finite numberI X - U -
tan xtan(x)Any finite numberI X - U -
arccos xacos(x)-1 to +1I X - - -
arcsin xasin(x)-1 to +1I X - U -
arctan xatan(x) - to + - X - U -
arctan y/xatan2(x,y) - to + - X - U -
Table E-16 Hyperbolic functions
ComputeSyntaxValid input rangeExceptions
cosh xcosh(x) - to + - X O - -
sinh xsinh(x) - to + - X O U -
tanh xtanh(x) - to + - X - - -
arccosh xacosh(x)1 to + I X - - -
arcsinh xasinh(x) - to + - X - U -
arctanh xatanh(x)-1 to +1I X - U -
Table E-17 Financial functions
ComputeSyntaxValid input rangeExceptions
Compound interestcompound(r,p)0 to + I X - - D
Annuityannuity(r,p)0 to + I X - - D
Table E-18 Error and gamma functions
ComputeSyntaxValid input range Exceptions
errorerf(x) - to + - X - U -
1 - errorerfc(x) - to + - X - U -
(x)gamma(x)0 to + I X O - -
ln(|(x)|)lgamma(x)0 to + I X O - -
Table E-19 Miscellaneous functions
ComputeSyntaxValid input rangeExceptions
Create NaNnan(tagp)character string- - - - -
Next representable number after x in direction of y nextafterd(x,y) - to + - X O U -
Hypotenusehypot(x,y) - to + - X O U -
Random number generatorrandomx(&x) 1to231+-2 - - - - -


[75] Return type of long int.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996