|
As Jon mentioned, RPG and COBOL have the same exact precedence rules...
https://www.ibm.com/docs/en/i/7.5?topic=arithmetic-expressions
For that matter every language I've heard of has the same precedence rules,
since precedence was defined long before computers came to be.
Division and multiplication have the same precedence and are thus evaluated
left to right.
Jon's other post about COBOL defaulting to ResDecPos explains why it might
seem as if COBOL has different precedence rules.
CHarles
On Mon, Aug 29, 2022 at 3:38 PM Jack Woehr via RPG400-L <
rpg400-l@xxxxxxxxxxxxxxxxxx> wrote:
In COBOL, the precedence of math operators is PEDMAS:explain?
*() ** / * + -*
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
--
--
*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
As an Amazon Associate we earn from qualifying purchases.
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.