PDA

View Full Version : What's up with %REM?

Guest.Visitor
05-14-2002, 11:34 AM
Yeah, it must be one of those days. Why would you expect a result of 55555 from <code>%REM(A:B)</code>? <code>%REM()</code> (like <code>%DIV()</code>) is defined to work with integer operands only and defined to give an integer result. (More precisely, they work with integer format, unsigned format, and decimal format with zero decimal places.) The integer remainder after dividing 123 by 27 is 15. The traditional decimal division operator has nothing whatsoever to do with integer division or remainder.

dchristie
05-14-2002, 11:34 AM
Having one of those days .... Consider the following which is based on the %REM IBM documentation: <pre> D A S 10I 0 INZ(123) D B S 10I 0 INZ(27) D DIV S 10I 0 D DIV2 S 15 5 D REM S 10I 0 D E S 10I 0 * C EVAL DIV = %DIV(A:B) C EVAL DIV2 = A/B C EVAL REM = %REM(A:B) C EVAL E = DIV*B + REM * C Eval *INLR = *On C Return </pre> If The result of DIV=%DIV(A:B)is 4. and the result of DIV2=A/B is 4.55555, why is REM=%REM(A:B) give a result of 15? Should it not be 55555?