Arc tangent function. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::atan](https://en.cppreference.com/w/cpp/numeric/math/atan). \param arg function argument \return arc tangent value of \a arg \exception FE_INVALID for signaling NaN \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding
| 3706 | /// \exception FE_INVALID for signaling NaN |
| 3707 | /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding |
| 3708 | inline half atan(half arg) |
| 3709 | { |
| 3710 | #ifdef HALF_ARITHMETIC_TYPE |
| 3711 | return half(detail::binary, detail::float2half<half::round_style>(std::atan(detail::half2float<detail::internal_t>(arg.data_)))); |
| 3712 | #else |
| 3713 | unsigned int abs = arg.data_ & 0x7FFF, sign = arg.data_ & 0x8000; |
| 3714 | if(!abs) |
| 3715 | return arg; |
| 3716 | if(abs >= 0x7C00) |
| 3717 | return half(detail::binary, (abs==0x7C00) ? detail::rounded<half::round_style,true>(sign|0x3E48, 0, 1) : detail::signal(arg.data_)); |
| 3718 | if(abs <= 0x2700) |
| 3719 | return half(detail::binary, detail::rounded<half::round_style,true>(arg.data_-1, 1, 1)); |
| 3720 | int exp = (abs>>10) + (abs<=0x3FF); |
| 3721 | detail::uint32 my = (abs&0x3FF) | ((abs>0x3FF)<<10); |
| 3722 | detail::uint32 m = (exp>15) ? detail::atan2(my<<19, 0x20000000>>(exp-15), (half::round_style==std::round_to_nearest) ? 26 : 24) : |
| 3723 | detail::atan2(my<<(exp+4), 0x20000000, (half::round_style==std::round_to_nearest) ? 30 : 28); |
| 3724 | return half(detail::binary, detail::fixed2half<half::round_style,30,false,true,true>(m, 14, sign)); |
| 3725 | #endif |
| 3726 | } |
| 3727 | |
| 3728 | /// Arc tangent function. |
| 3729 | /// This function may be 1 ULP off the correctly rounded exact result in ~0.005% of inputs for `std::round_to_nearest`, |