In real world cube root for a negative number should exist:
cuberoot(-1)=-1
, that means (-1)*(-1)*(-1)=-1
or
cuberoot(-27)=-3
, that me
7.12.7.1 The cbrt
functions
Synopsis
#include
double cbrt(double x);
float cbrtf(float x);
long double cbrtl(long double x);
Description
The cbrt
functions compute the real cube root of x
.
If you're curious, pow
can't be used to compute cube roots because one-third is not expressible as a floating-point number. You're actually asking pow
to raise -27.0
to a rational power very nearly equal to 1/3; there is no real result that would be appropriate.