comp.lang.ada
 help / color / mirror / Atom feed
* Differances in Ada and C++ on Sin and Cos
@ 2005-04-13 11:50 ich_bin_elvis
  2005-04-13 13:12 ` Marius Amado Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ich_bin_elvis @ 2005-04-13 11:50 UTC (permalink / raw)


Hi,

Does ada and C++ treat Cos and Sin functions different? I know arctan
and atan behaves different. But it seams like there is an different
behavior on the same program code written in ada and C++ on cos and sin
also. is there other functions  that behaves deifferent that I should
be aware of?

Regards
Ronny




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Differances in Ada and C++ on Sin and Cos
  2005-04-13 11:50 Differances in Ada and C++ on Sin and Cos ich_bin_elvis
@ 2005-04-13 13:12 ` Marius Amado Alves
  2005-04-13 13:57 ` Dmitry A. Kazakov
  2005-04-13 19:42 ` Jeffrey Carter
  2 siblings, 0 replies; 4+ messages in thread
From: Marius Amado Alves @ 2005-04-13 13:12 UTC (permalink / raw)
  To: ich_bin_elvis; +Cc: comp.lang.ada

> Does ada and C++ treat Cos and Sin functions different? I know arctan
> and atan behaves different. But it seams like there is an different
> behavior on the same program code written in ada and C++ on cos and sin
> also.

I'd be very surprised--and frightened--if the differences were not in 
precision only.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Differances in Ada and C++ on Sin and Cos
  2005-04-13 11:50 Differances in Ada and C++ on Sin and Cos ich_bin_elvis
  2005-04-13 13:12 ` Marius Amado Alves
@ 2005-04-13 13:57 ` Dmitry A. Kazakov
  2005-04-13 19:42 ` Jeffrey Carter
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry A. Kazakov @ 2005-04-13 13:57 UTC (permalink / raw)


On 13 Apr 2005 04:50:07 -0700, ich_bin_elvis@hotmail.com wrote:

> Does ada and C++ treat Cos and Sin functions different?

In Ada there are two variants of Cos/Sin, one of them has the argument
specified in terms of cycle, which may differ from the standard
mathematical definition (e.g. 2 Pi.) Do you mean this?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Differances in Ada and C++ on Sin and Cos
  2005-04-13 11:50 Differances in Ada and C++ on Sin and Cos ich_bin_elvis
  2005-04-13 13:12 ` Marius Amado Alves
  2005-04-13 13:57 ` Dmitry A. Kazakov
@ 2005-04-13 19:42 ` Jeffrey Carter
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Carter @ 2005-04-13 19:42 UTC (permalink / raw)


ich_bin_elvis@hotmail.com wrote:

> Does ada and C++ treat Cos and Sin functions different? I know arctan
> and atan behaves different. But it seams like there is an different
> behavior on the same program code written in ada and C++ on cos and sin
> also. is there other functions  that behaves deifferent that I should
> be aware of?

Ada generally requires greater accuracy from the elementary functions 
than other languages. ARM A.5.1 says

"The results of the Sin, Cos, Tan, and Cot functions with specified 
cycle are exact when the mathematical result is zero; those of the first 
two are also exact when the mathematical result is � 1.0."

A compiler that implements the Numerics Annex will also abide by the 
accuracy requirements of ARM G.2.4 (at least in strict mode, which may 
be the default mode; see ARM G.2). These can be difficult to read 
sometimes. I find

"The maximum relative error exhibited by each function is as follows:

     2.0 � EF.Float_Type'Model_Epsilon, in the case of the Sqrt, Sin, 
and Cos functions"

"The absolute value of the result of the Sin, Cos, and Tanh functions 
never exceeds one."

specific to Sin and Cos.

Note that for GNAT 3.15p, which completely implements the Numerics 
Annex, strict mode is the default and only mode for the elementary 
functions. This is probably true for later versions of GNAT as well.

-- 
Jeff Carter
"Apart from the sanitation, the medicine, education, wine,
public order, irrigation, roads, the fresh water system,
and public health, what have the Romans ever done for us?"
Monty Python's Life of Brian
80



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-04-13 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-13 11:50 Differances in Ada and C++ on Sin and Cos ich_bin_elvis
2005-04-13 13:12 ` Marius Amado Alves
2005-04-13 13:57 ` Dmitry A. Kazakov
2005-04-13 19:42 ` Jeffrey Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox