www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/17/04:14:22

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Date: Sun, 17 Feb 2002 11:12:20 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp AT delorie DOT com
Subject: Re: allegro and math libraries
In-Reply-To: <m%Gb8.37386$NP4.4356791@news20.bellglobal.com>
Message-ID: <Pine.SUN.3.91.1020217111159.24531I-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Sun, 17 Feb 2002, Brent Ritchie wrote:

> Just a suggestion, you shouldn't rely on *magic* numbers like 3.1415. In my
> opinion it's not good practice. I use this method.
> 
> const float pi = (atan(1)*4);

Fortran legacy, I suppose ;-)

I don't recommend to put such a great faith into the quality of the
`atan' library function: you'd be surprised how much some of them
suck, and will give you inaccurate results.  (The DJGPP version is
okay, though.)

Also, using integer "1" (without a period to signal a double) here is
dangerous: it will do evil things if you forget to include <math.h>.

So it is much better to use a provided symbol M_PI, which is exact,
and also saves some run-time computation.  M_PI is defined on
<math.h>.  The only downside is that M_PI isn't ANSI.

- Raw text -


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