Mail Archives: djgpp/1999/02/28/08:19:07
At 02:19 PM 2/28/99 +0200, you wrote:
>> const long double pi = 3.141592653589793
>
>Don't ``invent'' Pi, use the constant M_PI.
1. M_PI is a macro. 'Nuff said.
2. That value is accurate to the last decimal place, anyways.
>> template <class F> // 'F' as in 'Floating point'
>> inline F deg2rad (F deg) { return deg*pi/180.0; }
>
>You don't need to go to C++ just to have inline functions.
Not using gcc, but this does provide a deg2rad that works with floats,
doubles, and long doubles without any conversions being done.
>The macros Nate suggested don't have any side effects.
Well, those specific ones don't, as it just so happens, as long as you
don't pass something pathological as argument, but macros on the whole are
best avoided. C++ makes this easy with the consts, templates, and inlines.
--
.*. "Clouds are not spheres, mountains are not cones, coastlines are not
-() < circles, and bark is not smooth, nor does lightning travel in a
`*' straight line." -------------------------------------------------
-- B. Mandelbrot |http://surf.to/pgd.net
_____________________ ____|________ Paul Derbyshire pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|
- Raw text -