std::cbrt
Defined in header <cmath> | | |
|---|---|---|
float cbrt( float arg ); | (1) | (since C++11) |
double cbrt( double arg ); | (2) | (since C++11) |
long double cbrt( long double arg ); | (3) | (since C++11) |
double cbrt( Integral arg ); | (4) | (since C++11) |
的立方根。arg...
4%29一组过载或接受任意参数的函数模板积分型等于2%29%28double29%。
参数
arg | - | value of a floating-point or Integral type |
|---|
返回值
如果没有发生错误,则arg返回%283拉丁语Arg%29。
如果由于下流而发生范围错误,则返回舍入%29后的正确结果%28。
错误处理
错误按math_errhandling...
如果实现支持ieee浮点算法%28IEC 60559%29,
- 如果参数为±0或±∞,则返回不变。
- 如果论点是NaN,则返回NaN。
注记
std::cbrt(arg)不等于std::pow(arg, 1.0/3)因为std::pow不能将负基提高到小数指数。
例
二次
#include <iostream>
#include <cmath>
int main()
{
// normal use
std::cout << "cbrt(729) = " << std::cbrt(729) << '\n'
<< "cbrt(-0.125) = " << std::cbrt(-0.125) << '\n';
// special values
std::cout << "cbrt(-0) = " << std::cbrt(-0.0) << '\n'
<< "cbrt(+inf) = " << std::cbrt(INFINITY) << '\n';
}二次
产出:
二次
cbrt(729) = 9
cbrt(-0.125) = -0.5
cbrt(-0) = -0
cbrt(+inf) = inf二次
另见
pow | raises a number to the given power (xy) (function) |
|---|---|
sqrt | computes square root (√x) (function) |
hypot (C++11) | computes square root of the sum of the squares of two given numbers (√x2+y2) (function) |
c CBRT文件
© cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

