Gamma function. This function may be 1 ULP off the correctly rounded exact result for any rounding mode in <0.25% of inputs. See also:** Documentation for [std::tgamma](https://en.cppreference.com/w/cpp/numeric/math/tgamma). \param arg function argument \return gamma function value of \a arg \exception FE_INVALID for signaling NaN, negative infinity or negative integer arguments \exception FE_DIV
| 4010 | /// \exception FE_DIVBYZERO for 0 |
| 4011 | /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding |
| 4012 | inline half tgamma(half arg) |
| 4013 | { |
| 4014 | #if defined(HALF_ARITHMETIC_TYPE) && HALF_ENABLE_CPP11_CMATH |
| 4015 | return half(detail::binary, detail::float2half<half::round_style>(std::tgamma(detail::half2float<detail::internal_t>(arg.data_)))); |
| 4016 | #else |
| 4017 | unsigned int abs = arg.data_ & 0x7FFF; |
| 4018 | if(!abs) |
| 4019 | return half(detail::binary, detail::pole(arg.data_)); |
| 4020 | if(abs >= 0x7C00) |
| 4021 | return (arg.data_==0x7C00) ? arg : half(detail::binary, detail::signal(arg.data_)); |
| 4022 | if(arg.data_ >= 0xE400 || (arg.data_ >= 0xBC00 && !(abs&((1<<(25-(abs>>10)))-1)))) |
| 4023 | return half(detail::binary, detail::invalid()); |
| 4024 | if(arg.data_ >= 0xCA80) |
| 4025 | return half(detail::binary, detail::underflow<half::round_style>((1-((abs>>(25-(abs>>10)))&1))<<15)); |
| 4026 | if(arg.data_ <= 0x100 || (arg.data_ >= 0x4900 && arg.data_ < 0x8000)) |
| 4027 | return half(detail::binary, detail::overflow<half::round_style>()); |
| 4028 | if(arg.data_ == 0x3C00) |
| 4029 | return arg; |
| 4030 | return half(detail::binary, detail::gamma<half::round_style,false>(arg.data_)); |
| 4031 | #endif |
| 4032 | } |
| 4033 | |
| 4034 | /// \} |
| 4035 | /// \anchor rounding |