Each record has about 9 amount fields. Is there a way, without testing each
field, to have RPG round in the way that they want?
I can only get it to round up. {H- half adjust}
Thanks so much
~Barb
Barb wrote:
>
> I've been asked by the accounting dept to generate some report totals based
> on some input files. However, they want totals to be rounded based on
> .50...(>.5 :round up, <.5:round down).
>
> Each record has about 9 amount fields. Is there a way, without testing each
> field, to have RPG round in the way that they want?
No.
> I can only get it to round up. {H- half adjust}
True.
Make a func that adds .5 then move the result into an integer.
eg 100.1 + .5 = 100.6 -> 100
100.6 + .5 = 101.1 -> 101
--
Dr. Ugo Gagliardelli, Modena, Italy
Spaccamaroni andate a cagare/Spammers not welcome
Spamers iros a la mierda/Spamers allez vous faire foutre
Spammers loop schijten
You did not say what should happen to .50. If you want .50 to round
up like the values above .50, then half-adjust does what you want. If
you want .50 to stay at .50, .51 to .99 to round up, and .01 to .49 to
round down, then I would suggest writing a subprocedure to do it.
Ken
http://www.ke9nr.org/
Opinions expressed are my own and do not necessarily represent the views of my employer or anyone in their right mind.
Here's a little program that I ran in the debugger. After each eval(h) I
checked
"result" and the results were rounded as you describe.
D num s 5p 2
D result s 5p 0
C eval num = 1.49
C eval(h) result = num RESULT = 00001.
C eval num = 1.50
C eval(h) result = num RESULT = 00002.
C eval num = 1.51
C eval(h) result = num RESULT = 00002.
C seton
Can you post a similar little program that illustrates the problem you're
having? You're probably doing something more complicated than assigning one
value to another.
If you try to handle this yourself by adding .5 as Ugo suggests, be careful with
negative numbers (you have to add -.5 unless you want very strange rounding).
- Barbara