Int(), Round()

These two functions are for losing precision. INT() removes the decimal portion of a number. ROUND() lets you specify the desired precision and then it rounds more or less according to the usual rounding rules.

Usage

nNoDecimals = INT( nNumber )
nRounded = ROUND( nNumToRound, nPlaces )

Parameter

Value

Meaning

nNumber or nNumToRound

Numeric, Float, Integer, Double or Currency

Number to be processed.

nPlaces

0

Rounds to the nearest integer.

Positive

Rounds to the specified number of decimal places.

Negative

Rounds to the specified power of 10. For example, passing nPlaces=-2 rounds to the nearest hundred.


We were taught that when the first digit being dropped is 5, you look at the digit to its left—if it's even, you round down; if it's odd, you round up. ROUND() doesn't do it that way—it always rounds up on a 5. Beware of this if you're doing statistical or engineering calculations where such things matter.For positive numbers, INT() and FLOOR() are the same. For negative numbers, INT() is the same as CEILING().

Example

? INT(37.2738)          && Returns 37
? ROUND(37.2738,0)      && Returns 37
? ROUND(37.2738,1)      && Returns 37.3
? ROUND(37.2738,2)      && Returns 37.27
? ROUND(37.2738,3)      && Returns 37.274
? ROUND(37.2738,-1)   && Returns 40
? ROUND(37.2738,-2)     && Returns 0
? ROUND(-11.92,0)       && Returns -12
? ROUND(-11.92,1)       && Returns -11.9
? ROUND(-11.92,-1)      && Returns -10

See Also

Ceiling(), Floor(), Max(), Min()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .