Focal Point
Rounding whole numbers?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9711018331

November 10, 2004, 10:56 AM
<kvn>
Rounding whole numbers?
Is this possible or is WebFocus only able to round decimal places?
November 10, 2004, 11:39 AM
<Grzegorz>
I cannot find any rounding function in the standard WebFOCUS libraries (decimal format convertions automaticaly round decimal places), but ...

You can easily create your own rounding function, place it within the "library" procedure, and -INCLUDE it as necessary into the reports.

-* File library.fex --------------------------
DEFINE FUNCTION D_ROUND(NUMBER/D12.2, BASE/D8)
TMPNUM/D12 = NUMBER;
REMAINDER/D8 = DMOD(NUMBER, BASE, REMAINDER);
TESTVAL/D8 = BASE/2;

RETVAL/D12 = IF REMAINDER GE TESTVAL THEN
TMPNUM + (BASE - REMAINDER)
ELSE TMPNUM - REMAINDER;

D_ROUND/D12 = RETVAL;
END
-*
...
-*
-* End of the File library.fex -------------------


-* Sample report: ----------------------
-INCLUDE LIBRARY

TABLE FILE CAR
PRINT RETAIL_COST
COMPUTE RC_ROUNDED/D12 = D_ROUND(RETAIL_COST, 100); AS 'Rounded to 100'
BY CAR
END

Hope this helps
Grzegorz
November 10, 2004, 12:24 PM
<kvn>
This is the 2nd time you've helped me with a problem. Much appreciated.