Cubic root. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::cbrt](https://en.cppreference.com/w/cpp/numeric/math/cbrt). \param arg function argument \return cubic root of \a arg \exception FE_INVALID for signaling NaN \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
| 3237 | /// \exception FE_INVALID for signaling NaN |
| 3238 | /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding |
| 3239 | inline half cbrt(half arg) |
| 3240 | { |
| 3241 | #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH |
| 3242 | return half(detail::binary, detail::float2half<half::round_style>(std::cbrt(detail::half2float<detail::internal_t>(arg.data_)))); |
| 3243 | #else |
| 3244 | int abs = arg.data_ & 0x7FFF, exp = -15; |
| 3245 | if(!abs || abs == 0x3C00 || abs >= 0x7C00) |
| 3246 | return (abs>0x7C00) ? half(detail::binary, detail::signal(arg.data_)) : arg; |
| 3247 | for(; abs<0x400; abs<<=1, --exp); |
| 3248 | detail::uint32 ilog = exp + (abs>>10), sign = detail::sign_mask(ilog), f, m = |
| 3249 | (((ilog<<27)+(detail::log2(static_cast<detail::uint32>((abs&0x3FF)|0x400)<<20, 24)>>4))^sign) - sign; |
| 3250 | for(exp=2; m<0x80000000; m<<=1,--exp) ; |
| 3251 | m = detail::multiply64(m, 0xAAAAAAAB); |
| 3252 | int i = m >> 31, s; |
| 3253 | exp += i; |
| 3254 | m <<= 1 - i; |
| 3255 | if(exp < 0) |
| 3256 | { |
| 3257 | f = m >> -exp; |
| 3258 | exp = 0; |
| 3259 | } |
| 3260 | else |
| 3261 | { |
| 3262 | f = (m<<exp) & 0x7FFFFFFF; |
| 3263 | exp = m >> (31-exp); |
| 3264 | } |
| 3265 | m = detail::exp2(f, (half::round_style==std::round_to_nearest) ? 29 : 26); |
| 3266 | if(sign) |
| 3267 | { |
| 3268 | if(m > 0x80000000) |
| 3269 | { |
| 3270 | m = detail::divide64(0x80000000, m, s); |
| 3271 | ++exp; |
| 3272 | } |
| 3273 | exp = -exp; |
| 3274 | } |
| 3275 | return half(detail::binary, (half::round_style==std::round_to_nearest) ? |
| 3276 | detail::fixed2half<half::round_style,31,false,false,false>(m, exp+14, arg.data_&0x8000) : |
| 3277 | detail::fixed2half<half::round_style,23,false,false,false>((m+0x80)>>8, exp+14, arg.data_&0x8000)); |
| 3278 | #endif |
| 3279 | } |
| 3280 | |
| 3281 | /// Hypotenuse function. |
| 3282 | /// This function is exact to rounding for all rounding modes. |