Cosine function. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::cos](https://en.cppreference.com/w/cpp/numeric/math/cos). \param arg function argument \return cosine value of \a arg \exception FE_INVALID for signaling NaN or infinity \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
| 3561 | /// \exception FE_INVALID for signaling NaN or infinity |
| 3562 | /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding |
| 3563 | inline half cos(half arg) |
| 3564 | { |
| 3565 | #ifdef HALF_ARITHMETIC_TYPE |
| 3566 | return half(detail::binary, detail::float2half<half::round_style>(std::cos(detail::half2float<detail::internal_t>(arg.data_)))); |
| 3567 | #else |
| 3568 | int abs = arg.data_ & 0x7FFF, k; |
| 3569 | if(!abs) |
| 3570 | return half(detail::binary, 0x3C00); |
| 3571 | if(abs >= 0x7C00) |
| 3572 | return half(detail::binary, (abs==0x7C00) ? detail::invalid() : detail::signal(arg.data_)); |
| 3573 | if(abs < 0x2500) |
| 3574 | return half(detail::binary, detail::rounded<half::round_style,true>(0x3BFF, 1, 1)); |
| 3575 | if(half::round_style != std::round_to_nearest && abs == 0x598C) |
| 3576 | return half(detail::binary, detail::rounded<half::round_style,true>(0x80FC, 1, 1)); |
| 3577 | std::pair<detail::uint32,detail::uint32> sc = detail::sincos(detail::angle_arg(abs, k), 28); |
| 3578 | detail::uint32 sign = -static_cast<detail::uint32>(((k>>1)^k)&1); |
| 3579 | return half(detail::binary, detail::fixed2half<half::round_style,30,true,true,true>((((k&1) ? sc.first : sc.second)^sign) - sign)); |
| 3580 | #endif |
| 3581 | } |
| 3582 | |
| 3583 | /// Tangent function. |
| 3584 | /// This function is exact to rounding for all rounding modes. |