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?
The Language Ref. properly cautions that a constant declaration may
be necessary to control the constant types.
-- gil
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN