## Odd RPGLE Multiplication issue

pts.
Tags:
Application development
RPGLE
I have a RPGLE program that traverses through a bill of materials to do a cost roll up. Part of the code multiplies several quantities together to get the quantity needed at that level. The multiplication is not yielding the correct answer and I?m not sure why. Below is a small sample program that illustrates the problem. Your help will be greatly appreciated?. Thanks D @1 s 15s 6 inz(1) D @2 s 15s 6 inz(1) D @3 s 15s 6 inz(1) D @4 s 15s 6 inz(1) D @5 s 15s 6 inz(4.900000) D @tqty s 15s 6 C C eval @tqty = (@1 * @5) C* this returns 4.900000 C* C eval @tqty = (((((@1 * @2) C * @3) * @4) C * @5)) C* this returns 4.000000 ? C* C eval *inlr = *on C return

Thanks. We'll let you know when a new response is added.

Hi Hoffman

I’ve seen this discussed before (on Midrange.Com I think) and it’s something to do with how the compiler interprets the EVAL statement with so many 15.6 length fields.

I can’t remember what the exact explanation was, but if you break the EVAL down into its component parts then everything works fine. E.g:

C Eval @tqty = @1 * @2
C Eval @tqty = @tqty * @3
C Eval @tqty = @tqty * @4
C Eval @tqty = @tqty * @5

Will give you the correct result.

All the best

Jonathan

## Discuss This Question: 3 Replies

Thanks. We'll let you know when a new response is added.