On 2020-09-07 14:56, Seymour J Metz wrote:
No: see
https://www.ibm.com/support/knowledgecenter/SSY2V3_5.3.0
/lr/resarithoprt.html#resarithoprt__fig16,
Tables 3 and 4. For 4/3, the scale factor is 1, not 0.

4 is FIXED DECIMAL (1,0).
3 IS fixed decimal (1,0).
4/3 is fixed decimal (15,14).*
See Table 16.
It's been that way since 1965.

____________
* given that the maximum precision is 15.

________________________________________
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> on
behalf of Robin Vowels <robi...@dodo.com.au>
Sent: Sunday, September 6, 2020 8:09 PM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Constant Identifiers

----- Original Message -----
From: "Paul Gilmartin" <0000000433f07816-dmarc-requ...@listserv.ua.edu>
Sent: Sunday, September 06, 2020 11:07 PM


On Sun, 6 Sep 2020 17:25:45 +1000, Robin Vowels wrote:

And C:
662 $ cat typetest.c
#include <stdio.h>
int main() {
    printf( "%10.6f\n",   4/3 * 3.14159 );
    printf( "%10.6f\n", 4.0/3 * 3.14159 ); }
663 $ gmake typetest &&amp; ./typetest
cc     typetest.c   -o typetest
  3.141590
  4.188787

It ought to depend on the types of the operands of the polymorphic
operator, '/'.  What are the default types of '4' and '3'?

The type and precision of constants are as written.
Thus, both 4 and 3 are FIXED DECIMAL (1).

 Does PL/I entirely lack an integer divide?

PL/I can do integer division.  When the operands are of
maximum precision, anm integer result is produced.
Thus, for
DECLARE (I, J) FIXED BINARY (31);
then
I  / J;
produces an integer result of precision (31,0).
Similarly of I and J were defined with maximum precision.

Also, as Seymour Metz points out, the DIVIDE built-in function may
be used to produce an integer result.

Or, you can go ahead with the division, and the result will be truncated
to an integer by assigning to an integer variable.  However, that
wastes time with unnecessary computation.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to