From: "Robert Prins" <robert.ah.pr...@gmail.com>
Sent: Monday, September 07, 2020 3:42 AM
On 2020-09-06 13:07, Paul Gilmartin wrote:
On Sun, 6 Sep 2020 17:25:45 +1000, Robin Vowels wrote:
Beware! Than might left-associate as:
volume = ( 4/3 ) * 3.14159 * radius**3
... and the quotient of integers, 4/3, is 1.
No it's not. 4/3 yields 1.33333333333333.. to 15 digits in PL/I.
You're thinking of FORTRAN.
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 && ./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'? Does PL/I
entirely lack an integer divide?
No,
Yes it does.
In an earlier letter, I pointed out that when both integer operands
for division are of the same type and are of maximum precision
PL/I produces an integer result.
if the receiving variable is an integer without fractional part, PL/I truncates.
Yes, it can do that too.
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN