delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/18/04:56:17

Sender: kaa AT intel DOT com
Message-Id: <367A27BD.CA237860@intel.com>
Date: Fri, 18 Dec 1998 10:00:29 +0000
From: Kurt Alstrup <kurt DOT alstrup AT intel DOT com>
Organization: Intel Denmark Aps
X-Mailer: Mozilla 4.5 [en] (X11; U; Linux 2.0.36 i686)
X-Accept-Language: en
Mime-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: sin() and cos() ???
References: <199812171034 DOT FAA02881 AT delorie DOT com> <4 DOT 1 DOT 19981218094138 DOT 00a7cf00 AT hal DOT nt DOT tuwien DOT ac DOT at>
Reply-To: djgpp AT delorie DOT com

A better way would be to calculate pi once by eg

 double pi = 4 * atan(1.0);

it should give you pi in a precision suitable for the
math library.

Just my two cents ..

Anton Helm wrote:
> 
> At 18:27 17.12.98 +0000, Arthur wrote:
> 
> >I think in math.h, there is a definition called PI. This is much more
> >accurate than what you've got here.
> >
> >So you can use sin(x*PI/180); instead (easier).
> >
> 
> PI is not ANSI (checked) and as far as I know
> it isn't POSIX either (unchecked).
> 
> So if you want a portable code you should
> have a
> 
> #ifndef PI
> #define PI 3.1415.....
> #endif
> 
> somewhere (well, preferably in a *.h  file) in your program.
> 
> Although PI and M_PI are #defined on lots of systems you
> can't rely on them.
> 
> Tony

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019