4/3 yields 1.3, 04/3 yields 1332, ...

However, DIVIDE(4,3,16,15) yields 1.3...2 to 15 digits


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3


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

From: "Paul Gilmartin" <0000000433f07816-dmarc-requ...@listserv.ua.edu>
To: <IBM-MAIN@LISTSERV.UA.EDU>
Sent: Sunday, September 06, 2020 1:33 PM


On Sat, 5 Sep 2020 08:13:42 +1000, Robin Vowels wrote:
>
>As for writing formulas, I prefer to follow a well-known formula, thus:
>
>volume = 4/3 * 3.14159 * radius**3
>
Beware!  Than might left-associate as:
    volume = ( 4/3 ) * 3.14159 * radius**3

"might"?
Evaluation MUST proceed left to right.
So, whether it is written as 4/3 or (4/3), the division will be done first.

> ... and the quotient of integers, 4/3, is 1.

As I indicaed before, 4/3 yields 1.3333333.....to 15 digits.

>However, if I'm interested in efficiency, I'd prefer
>
>volume = 4 * 3.14159E0 / 3 * radius**3
>
... (and correct.)

Yes, it's correct, but I wrote it that way in order to avoid unnecessary
conversions and arithmetic in fixed-point.

---
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

----------------------------------------------------------------------
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