Focal Point
ROUND UP TO WHOLE NUMBER

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

June 03, 2008, 03:32 PM
Tomsweb
ROUND UP TO WHOLE NUMBER
Is it possible to round uop to next whole # with division in dialogue manager?

-SET &LIMIT = 5;
-SET &NRECS = 3;
-SET &RMAX = (&LIMIT/&NRECS);

or, how do I get a decimal in the remainder to
round it up myself?

Thanks!

Thanks!


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
June 03, 2008, 03:50 PM
smiths
Add .5 to your result.

So you would have:

-SET &LIMIT = 5;
-SET &NRECS = 3;
-SET &RMAX = (&LIMIT/&NRECS) + .5;


Regards,
Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
June 03, 2008, 04:23 PM
j.gross
-SET &RMAX = (&LIMIT/&NRECS) + .5;

would round 11/10 down rather than up.

Dialog Mgr evaluates the right-hand expression in floating-point arithmetic, and then truncates the result to an integer.

Use:

-SET &RMAX = (&LIMIT+(&NRECS-1))/&NRECS ;

[assuming the values will never be negative]


- Jack Gross
WF through 8.1.05
June 03, 2008, 04:54 PM
smiths
Ah yes, good point Jack. My solution is for regular rounding, where 2.49 becomes 2, and 2.5 becomes 3.

I like your formula for rounding up.

Sean


------------------------------------------------------------------------
PROD: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
TEST: WebFOCUS 7.6.2 on Unix AIX/Tomcat/Servlet Mode
June 03, 2008, 05:02 PM
Tomsweb
quote:
-SET &RMAX = (&LIMIT+(&NRECS-1))/&NRECS ;



Thanks! j.g. and smiths

j.g. > I never heard of your method.


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36