June 03, 2008, 03:32 PM
TomswebROUND 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!
June 03, 2008, 03:50 PM
smithsAdd .5 to your result.
So you would have:
-SET &LIMIT = 5;
-SET &NRECS = 3;
-SET &RMAX = (&LIMIT/&NRECS) + .5;
Regards,
Sean
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]
June 03, 2008, 04:54 PM
smithsAh 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
June 03, 2008, 05:02 PM
Tomswebquote:
-SET &RMAX = (&LIMIT+(&NRECS-1))/&NRECS ;
Thanks! j.g. and smiths
j.g. > I never heard of your method.