Check the COMPUTE sentence help. There you will be pointed to proper "functions" to rounding/truncating numbers.
Hi ,
You could make use of the following key words
<b>ceil</b> <i>Smallest integer number that is not smaller than the value of the argument arg.</i> <b>floor</b> <i>Largest integer number that is not larger than the value of the argument arg.</i>
Thanks..
Preetham S
Define a new variable type P with required decimals.. and assign the value to this new variable automatic rounding take places.
Ex: Data : amount type p decimals 2.
amount = '231233.548' .
Write amount. "AMOUNT will have 231233.55
amount = '3342322.573'.
Write amount. "AMOUNT will have 3342322.57
Close the thread if your question is answered.
Regards,
SaiRam
Option
... ROUND r
Effect
Scaled output of a field of type P.
The decimal point is first moved r places to the left ( r > 0) or to the right ( r < 0); this is the same as dividing with the appropriate exponent 10** r. The value determined in this way is output with the valid number of digits before and after the decimal point. If the decimal point is moved to the left, the number is rounded.
For further information about the interaction between the formatting options CURRENCY and DECIMALS, see the notes below.
Example
Effect of different ROUND specifications:
DATA: X TYPE P DECIMALS 2 VALUE '12493.97'.
WRITE: /X ROUND -2, "output: 1,249,397.00
/X ROUND 0, "output: 12,493.97
/X ROUND 2, "output: 124.94
/X ROUND 5, "output: 0.12
reward points to all helpful answers
kiran.M
Add comment