From: Al Christians <achrist@easystreet.com>
Subject: Re: An interesting object lesson (Ada vs C)
Date: 1998/04/26
Date: 1998-04-26T00:00:00+00:00 [thread overview]
Message-ID: <354428B4.674A@easystreet.com> (raw)
In-Reply-To: 6hvpf2$77d$1@news.hal-pc.org
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
next prev parent reply other threads:[~1998-04-26 0:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-26 0:00 An interesting object lesson (Ada vs C) Robert Dewar
1998-04-26 0:00 ` Jonathan Guthrie
1998-04-26 0:00 ` Robert Dewar
1998-04-29 0:00 ` Keith Thompson
1998-05-01 0:00 ` Jonathan Guthrie
1998-04-26 0:00 ` Robert Dewar
1998-05-01 0:00 ` Jonathan Guthrie
1998-04-26 0:00 ` Al Christians [this message]
1998-04-30 0:00 ` John McCabe
1998-04-26 0:00 ` Andi Kleen
1998-04-27 0:00 ` Samuel Tardieu
1998-04-27 0:00 ` Aaro Koskinen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox