Cbrt v0.1.0

Source
Returns the cube root.

Package: Math

Signature

func Cbrt(x: float64) -> float64;
func Cbrt(x: float32) -> float32;

Parameters

NameTypeDescription
xfloat64 / float32Any value.

Returns

The real cube root of x. Unlike Sqrt, the result is defined for a negative x: Cbrt(-8.0) is -2.0. Cbrt(NaN) and Cbrt(±Inf) are themselves, and Cbrt(±0.0) preserves the sign of the zero.

Example

import Math::Cbrt;

func Main() -> int {
    let a = Cbrt(27.0); // 3.0
    let b = Cbrt(-8.0); // -2.0
    return 0;
}

See also

  • Math — the package overview
  • Sqrt — square root
  • Pow — general exponentiation (Pow(x, 1.0 / 3.0) is not equivalent for negative x)