Exponent implementation. \param arg number to query \return floating point exponent
| 1786 | /// \param arg number to query |
| 1787 | /// \return floating point exponent |
| 1788 | static half logb(half arg) |
| 1789 | { |
| 1790 | int abs = arg.data_ & 0x7FFF; |
| 1791 | if(!abs) |
| 1792 | return half(binary, 0xFC00); |
| 1793 | if(abs < 0x7C00) |
| 1794 | { |
| 1795 | int exp = (abs>>10) - 15; |
| 1796 | if(abs < 0x400) |
| 1797 | for(; abs<0x200; abs<<=1,--exp) ; |
| 1798 | uint16 bits = (exp<0) << 15; |
| 1799 | if(exp) |
| 1800 | { |
| 1801 | unsigned int m = std::abs(exp) << 6, e = 18; |
| 1802 | for(; m<0x400; m<<=1,--e) ; |
| 1803 | bits |= (e<<10) + m; |
| 1804 | } |
| 1805 | return half(binary, bits); |
| 1806 | } |
| 1807 | if(abs > 0x7C00) |
| 1808 | return arg; |
| 1809 | return half(binary, 0x7C00); |
| 1810 | } |
| 1811 | |
| 1812 | /// Enumeration implementation. |
| 1813 | /// \param from number to increase/decrease |