$ROUND returns a value that is the input value rounded by the specified or implied factor.
This function has the following format:
{FACTOR=f }
$ROUND (expression,{ATTR=id } )
Defines a numeric expression.
Indicates that the value is obtained by rounding the numeric expression to the nearest value according to a rounding factor.
A rounding factor. This factor is any numeric identifier or numeric literal with a positive value. If the factor has a negative value, the sign is ignored and assumed to be positive. If the factor is 0, no rounding is performed.
For example, if the rounding factor is 1, the numeric expression is rounded to the nearest integer (with the rule that a value with a fractional part equal to or greater than .5 rounds to the next higher number). A rounding factor of .1 rounds the numeric expression to the nearest tenth. A rounding factor of 25 rounds the expression to the nearest multiple of 25, and so on.
Indicates that the value is obtained by rounding to the nearest unit based on the attributes of the specified identifier. For example, if the specified identifier has 2 decimal places, that is equivalent to a FACTOR of .01.
The identifier of a numeric field whose attributes designate the rounding factor. If the specified field is subscripted, the subscript is not required as part of the identifier.
Examples
SET I = $ROUND (257.6,FACTOR=1) : result is 258
SET I = $ROUND (257.2,FACTOR=1) : result is 257
SET I = $ROUND (257.2,FACTOR=0) : result is 257.2
SET I = $ROUND (257,FACTOR=50) : result is 250
SET I = $ROUND (285,FACTOR=50) : result is 300
SET I = $ROUND (‑285,FACTOR=50) : result is ‑300
SET I = $ROUND (2.378,FACTOR=.01): result is 2.38
SET I = $ROUND (2.372,FACTOR=.01): result is 2.37
SET I = $ROUND (2.378,ATTR=K) : assuming K has 2
: decimal places,
: result is 2.38
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|