| 882 | /// \exception FE_UNDERFLOW on underflows |
| 883 | /// \exception FE_INEXACT if value had to be rounded or \a I is `true` |
| 884 | template<std::float_round_style R,unsigned int F,bool S,bool N,bool I> unsigned int fixed2half(uint32 m, int exp = 14, unsigned int sign = 0, int s = 0) |
| 885 | { |
| 886 | if(S) |
| 887 | { |
| 888 | uint32 msign = sign_mask(m); |
| 889 | m = (m^msign) - msign; |
| 890 | sign = msign & 0x8000; |
| 891 | } |
| 892 | if(N) |
| 893 | for(; m<(static_cast<uint32>(1)<<F) && exp; m<<=1,--exp) ; |
| 894 | else if(exp < 0) |
| 895 | return rounded<R,I>(sign+(m>>(F-10-exp)), (m>>(F-11-exp))&1, s|((m&((static_cast<uint32>(1)<<(F-11-exp))-1))!=0)); |
| 896 | return rounded<R,I>(sign+(exp<<10)+(m>>(F-10)), (m>>(F-11))&1, s|((m&((static_cast<uint32>(1)<<(F-11))-1))!=0)); |
| 897 | } |
| 898 | |
| 899 | /// Convert IEEE single-precision to half-precision. |
| 900 | /// Credit for this goes to [Jeroen van der Zijp](ftp://ftp.fox-toolkit.org/pub/fasthalffloatconversion.pdf). |
nothing calls this directly
no test coverage detected