In search of cbrt() ...

Craig Kolb craig at weedeater.math.yale.edu
Thu Dec 13 13:10:33 AEST 1990


In article <Dec.12.18.31.04.1990.3356 at paul.rutgers.edu>
	rcruz at paul.rutgers.edu (Rafael Cruz) writes:

>However, the  routines  to  compute cubic  and
>quartic roots make use of the library function cbrt().  This library
>is in the Unix math library but TC doesn't seem to support it. 

Sad but true.  Many math libraries don't have a cbrt().

Eric Haines was kind enough to point out this problem
and to provide the fix that appears in the latest Graphics Gems
distribution on weedeater.math.yale.edu:~ftp/pub/GraphicsGems/src:

#ifdef NOCBRT
#define     cbrt(x)     ((x) > 0.0 ? pow((double)(x), 1.0/3.0) : \
                          ((x) < 0.0 ? -pow((double)-(x), 1.0/3.0) : 0.0))
#endif

Stick the above lines in the header of Roots3And4.c, define NOCBRT,
and you should be all set.

Craig



More information about the Comp.lang.c mailing list