jlowary | 8 Dec 20:26 2005

Round/Truncate in RPG &RPGLE

Has any one come across a Rounding/Truncation problem in RPG and RGPLE? If 
we a have a negative number with 2-decimals and do truncation to  a field 
with no decimals for positive numbers it just drops the cents so 12.75 
becomes 12 and 12.05 becomes 12,  but for negative numbers a -12.75 be 
comes -13  and a -12.05 becomes -13. 

If we do half ajust then the 12.75 goes to 13 or  -13 respectivly  and the 
12.05 goes 12 and -12.

Seems like negative truncation is wrong becaue when we check this with a 
query it actually truncates on negatives not rounding down to the lower 
number.

Any thoughts? (or am I just off in the head today?)

Thanks,

-- Jim Lowary
ToastMaster/Salton, Inc.
--

-- 
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@...
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@...
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

rob | 8 Dec 21:13 2005

Re: Round/Truncate in RPG &RPGLE

how does one "do truncation"?  Are you MOVEing the field from the one 
field to the other?  Are you using z-add?  Are you using eval?

Rob Berendt
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com

jlowary@... 
Sent by: rpg400-l-bounces+rob=dekko.com@...
12/08/2005 02:26 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@...>

To
rpg400-l@...
cc

Fax to

Subject
Round/Truncate in RPG &RPGLE

Has any one come across a Rounding/Truncation problem in RPG and RGPLE? If 

(Continue reading)

HauserSSS | 9 Dec 15:52 2005
Picon

AW: Round/Truncate in RPG &RPGLE

Hi Rob,

we use built-in-functions like %Dec() or %Int() to achieve truncation.
For rounding wie use %DecH() or %IntH().

Birgitta

-----Ursprungliche Nachricht-----
Von: rpg400-l-bounces@...
[mailto:rpg400-l-bounces@...]Im Auftrag von rob@...
Gesendet: Donnerstag, 8. Dezember 2005 21:14
An: RPG programming on the AS400 / iSeries
Betreff: Re: Round/Truncate in RPG &RPGLE

how does one "do truncation"?  Are you MOVEing the field from the one 
field to the other?  Are you using z-add?  Are you using eval?

Rob Berendt
--

-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com

jlowary@... 
Sent by: rpg400-l-bounces+rob=dekko.com@...
12/08/2005 02:26 PM
(Continue reading)

jlowary | 9 Dec 15:31 2005

Re: Round/Truncate in RPG &RPGLE

Rob,

In this case just a straight add or subtract.   The first  field has 2 
decimals and the one being added to (or subtracted from) has no decimals

ie:  ADD       NET$          TRUNCK           11 0  (where NET$ is  13 2)

Even tried doing:

NET$          MULT   -1                  POS                13 2 
                     SUB       POS           TRUNCK 

and we get the same results.  If we do a half-adjust on the MULT then it 
works as expected (less than .50 it drops the decimals >= .50 then rounds 
up) or if we define POS as 13 0 this also works (it drop the decimals), 
but on this I would expect it to ignore the decimals on the subtract and 
it doesn't.

Regards,
-- Jim

>how does one "do truncation"?  Are you MOVEing the field from the one 
>field to the other?  Are you using z-add?  Are you using eval?
>
>Rob Berendt
--

-- 
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@...
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
(Continue reading)


Gmane