In search of cbrt() ...
Doug Gwyn
gwyn at smoke.brl.mil
Sat Dec 15 07:55:06 AEST 1990
In article <4502 at goanna.cs.rmit.oz.au> ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>> However, if all it does is extract a cube-root, it's trivial to emulate:
>> #include <math.h>
>> #define cubrt(x) pow(x,1.0/3.0)
>That doesn't quite do the job. cbrt(-8.0) is -2.0, but pow(-8.0, 1.0/3.0)
>prints "DOMAIN error" and returns 0.0.
Obviously. And there are also complex cube roots, etc. I assumed
that the operand was non-negative for simplicity, since it might be
known to be so in the particular application.
More information about the Comp.lang.c
mailing list