The Trunc function returns the truncation of a numeric value. Normally, the truncation eliminates the trailing decimal portion of the number. Alternatively, an optional number of trailing decimal digits can be specified.
Observe: the result will never in exponential form. Consequently, the resulting number can be long.
The numeric value is NOT rounded upward when the digit that follows the truncation position is greater than or equal to 5.
result = Trunc( number [, n ] ) |
Examples:
say Trunc( 42.3 ) -- shows: 42 say Trunc( 41.5 ) -- shows: 41, Surprise ! say Trunc( 41.95, 1 ) -- shows: 41.9 say Trunc( 41.95, 3 ) -- shows: 41.950 say Trunc( 3988292384 / 2 ) -- shows: 1994146190 |