comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Differances in Ada and C++ on Sin and Cos
Date: Wed, 13 Apr 2005 19:42:36 GMT
Date: 2005-04-13T19:42:36+00:00	[thread overview]
Message-ID: <MCe7e.5977$An2.5475@newsread2.news.pas.earthlink.net> (raw)
In-Reply-To: <1113393007.545506.191160@l41g2000cwc.googlegroups.com>

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



      parent reply	other threads:[~2005-04-13 19:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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