Hi,
have you thought about using the SQL scalar function CEILING (or short
version CEIL)?
From the SQL Reference:
The CEIL or CEILING function returns the smallest integer value that is
greater than or equal to expression.
Exec SQL Set :MyIntResult = Ceiling(:MyDec);
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im
Auftrag von Lance Gillespie
Gesendet: Friday, 27. February 2009 23:39
An: rpg400-l@xxxxxxxxxxxx
Betreff: Rounding up
I have a situation where I need my results rounded up if they are not exact.
As in:
2 * 1.01 = 3
2 * 1.50 = 3
2 * 1.51 = 4
The source and target numbers are 7,0 and the factor is a constant.
I thought:
target = %dech(source * 1.01) : 7 : 0)
or maybe
target = %dech(source * 1.01) : 9 : 2)
would do it, but no joy.
I suppose I could do the calcs twice with %dec, once to a 7,0 result and
once to a 9,2 result
(assuming %dec truncates) and then add one to the 7,0 result if the two are
not equal, but
I would rather not.
Is there some way to force these calcs to round up if not exact?
Thanks,
Lance
As an Amazon Associate we earn from qualifying purchases.