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 2 - The PowerPC Numerics C Implementation
Chapter 9 - Conversion Functions


Rounding Floating-Point Numbers to Integers

MathLib provides six functions that convert floating-point numbers to integers and return the integer in a floating-point type. The first is the rint function, which performs the round-to-integer operation as described in Chapter 6, "Numeric Operations and Functions." The other functions either round in a specific direction or perform a variation of the rint operation.
ceil(x) Returns the nearest integer not less than x.
floor(x) Returns the nearest integer not greater than x.
nearbyint(x) Returns the nearest integer to x in the current rounding direction.
round(x) Adds 1/2 to the magnitude of x and chops to an integer.
trunc(x) Truncates the fractional part of x.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996