Common logarithm. This function is exact to rounding for all rounding modes. See also:** Documentation for [std::log10](https://en.cppreference.com/w/cpp/numeric/math/log10). \param arg function argument \return logarithm of \a arg to base 10 \exception FE_INVALID for signaling NaN or negative argument \exception FE_DIVBYZERO for 0 \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rou
| 3087 | /// \exception FE_DIVBYZERO for 0 |
| 3088 | /// \exception FE_OVERFLOW, ...UNDERFLOW, ...INEXACT according to rounding |
| 3089 | inline half log10(half arg) |
| 3090 | { |
| 3091 | #ifdef HALF_ARITHMETIC_TYPE |
| 3092 | return half(detail::binary, detail::float2half<half::round_style>(std::log10(detail::half2float<detail::internal_t>(arg.data_)))); |
| 3093 | #else |
| 3094 | int abs = arg.data_ & 0x7FFF, exp = -15; |
| 3095 | if(!abs) |
| 3096 | return half(detail::binary, detail::pole(0x8000)); |
| 3097 | if(arg.data_ & 0x8000) |
| 3098 | return half(detail::binary, (arg.data_<=0xFC00) ? detail::invalid() : detail::signal(arg.data_)); |
| 3099 | if(abs >= 0x7C00) |
| 3100 | return (abs==0x7C00) ? arg : half(detail::binary, detail::signal(arg.data_)); |
| 3101 | switch(abs) |
| 3102 | { |
| 3103 | case 0x4900: return half(detail::binary, 0x3C00); |
| 3104 | case 0x5640: return half(detail::binary, 0x4000); |
| 3105 | case 0x63D0: return half(detail::binary, 0x4200); |
| 3106 | case 0x70E2: return half(detail::binary, 0x4400); |
| 3107 | } |
| 3108 | for(; abs<0x400; abs<<=1,--exp) ; |
| 3109 | exp += abs >> 10; |
| 3110 | return half(detail::binary, detail::log2_post<half::round_style,0xD49A784C>( |
| 3111 | detail::log2(static_cast<detail::uint32>((abs&0x3FF)|0x400)<<20, 27)+8, exp, 16)); |
| 3112 | #endif |
| 3113 | } |
| 3114 | |
| 3115 | /// Binary logarithm. |
| 3116 | /// This function is exact to rounding for all rounding modes. |