× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Nothing unusual - it is based on trying to maintain maximum accuracy within the bounds of the 63 digit maximum precision. It is all spelled out in the manual https://www.ibm.com/docs/en/i/7.5?topic=expressions-precision-rules-numeric-operations <https://www.ibm.com/docs/en/i/7.5?topic=expressions-precision-rules-numeric-operations>

The only real difference from other languages with decimal precision rules (like COBOL and PL/I for example) is the option to use ResDecPos which ensures that a minimum decimal accuracy is maintained at the potential expense of integer capacity. ResDecPos in my opinion makes RPG behave more as you would expect - I would love for it to have been the default but lost that battle. Basically the default is PL/I behaviour and ResDecPos is COBOL.


Jon P.

On Aug 29, 2022, at 6:46 PM, Don Brown via RPG400-L <rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:

Hi Jon

Just curious for the intermediate calculation what precision is used ?
(Not that it would make much difference unless zero decimal places)

Cheers

Don





From: "Jon Paris" <jon.paris@xxxxxxxxxxxxxx>
To: "RPG programming on IBM i" <rpg400-l@xxxxxxxxxxxxxxxxxx>
Date: 30/08/2022 08:32 AM
Subject: Re: Calculation gives wrong result
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx>



RPG rules are the same as COBOL.


Jon P.

On Aug 29, 2022, at 5:37 PM, Jack Woehr via RPG400-L
<rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:

In COBOL, the precedence of math operators is PEDMAS:
*() ** / * + -*

In RPG, multiplication and division have equal precedence, so the first
encountered is the first executed


On Mon, Aug 29, 2022 at 2:57 PM Justin Taylor <jtaylor.0ab@xxxxxxxxx>
wrote:

Both of these should give 4:
7 * (4 / 7)
7 * 4 / 7

RPG gives 3 and 4 as the result. I assume it has something to do with
intermediate result variables, but I can't see how. Can someone
explain?


--

*JACK WOEHR, IBM Champion 2021-2022
<https://www.credly.com/users/jack-woehr/badges>*

*SENIOR IBM i ENGINEER*

303.847.8442
jwoehr@xxxxxxxxxxxxxxxxxxxxxxxx
stay connected
<https://www.linkedin.com/company/absolute-performance-inc./>

<https://www.absolute-performance.com/>
www.absolute-performance.com

NON-DISCLOSURE NOTICE: This communication including any and all
attachments is for the intended recipient(s) only and may contain

confidential and privileged information. If you are not the intended
recipient of this communication, any disclosure, copying further

distribution or use of this communication is prohibited. If you
received
this communication in error, please contact the sender and

delete/destroy all copies of this communication immediately.
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com

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

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com




--
This email has been scanned for computer viruses. Although MSD has taken reasonable precautions to ensure no viruses are present in this email, MSD cannot accept responsibility for any loss or damage arising from the use of this email or attachments..
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.