From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b8effe21a2a8e1cb X-Google-Attributes: gid103376,public From: Al Christians Subject: Re: An interesting object lesson (Ada vs C) Date: 1998/04/26 Message-ID: <354428B4.674A@easystreet.com>#1/1 X-Deja-AN: 348003073 Content-Transfer-Encoding: 7bit References: <6hvpf2$77d$1@news.hal-pc.org> Mime-Version: 1.0 Reply-To: achrist@easystreet.com Content-Type: text/plain; charset=us-ascii Organization: Trillium Resources Corporation Newsgroups: comp.lang.ada Date: 1998-04-26T00:00:00+00:00 List-Id: Jonathan Guthrie wrote: > > > Elapsed time to my solution of the problem: 45 seconds. Eliminate the > warnings, and the code gives (on my computer) > arctan 0.5 = 0.463648 > Clock ticks: 1933 > > > arctan 0 = 3.25435e-229 > > Clock ticks: 2160 > > Wow! I've got a faster computer! (I didn't know that was possible! > Maybe it isn't possible. What value of CLOCKS_PER_SEC does he > have? Mine is 100.) > > > How did x get set to 0!?!?!?!? > > It didn't. It got DISPLAYED as 0. That's what happens when you use > compiler-specific extensions (as "long double" is, at least for the > time being) without understanding the underlying mechanisms. By the > mechanism that printf uses to accept parameters, it had every reason to > expect that you would pass it a double, but you passed it a long > double. > If x didn't get changed, howcome the answers for arctan are so different? I put the code posted into MS VC++ v5 with the strictest warning level, and I got the 0.463648 answer (looks reasonable for arctan 0.5) with no warnings at all. MingW32, based on GCC gives the warnings and the arctan 0 answer. I guess that MS would probably say that you don't need to issue the warning if you don't drop the ball. This obviously has profound implications for Ada, but I won't mention them here for lack of interest in compiler/vendor/ .../ .../language wars. Al