| 933 | *----------------------------------------------------------------------------*/ |
| 934 | |
| 935 | static float64 roundAndPackFloat64(flag zSign, int zExp, uint64_t zSig, |
| 936 | float_status *status) |
| 937 | { |
| 938 | int8_t roundingMode; |
| 939 | flag roundNearestEven; |
| 940 | int roundIncrement, roundBits; |
| 941 | flag isTiny; |
| 942 | |
| 943 | roundingMode = status->float_rounding_mode; |
| 944 | roundNearestEven = ( roundingMode == float_round_nearest_even ); |
| 945 | switch (roundingMode) { |
| 946 | case float_round_nearest_even: |
| 947 | case float_round_ties_away: |
| 948 | roundIncrement = 0x200; |
| 949 | break; |
| 950 | case float_round_to_zero: |
| 951 | roundIncrement = 0; |
| 952 | break; |
| 953 | case float_round_up: |
| 954 | roundIncrement = zSign ? 0 : 0x3ff; |
| 955 | break; |
| 956 | case float_round_down: |
| 957 | roundIncrement = zSign ? 0x3ff : 0; |
| 958 | break; |
| 959 | default: |
| 960 | abort(); |
| 961 | } |
| 962 | roundBits = zSig & 0x3FF; |
| 963 | if ( 0x7FD <= (uint16_t) zExp ) { |
| 964 | if ( ( 0x7FD < zExp ) |
| 965 | || ( ( zExp == 0x7FD ) |
| 966 | && ( (int64_t) ( zSig + roundIncrement ) < 0 ) ) |
| 967 | ) { |
| 968 | #ifdef SOFTFLOAT_68K |
| 969 | float_raise( float_flag_overflow, status ); |
| 970 | saveFloat64Internal( zSign, zExp, zSig, status ); |
| 971 | if ( roundBits ) float_raise( float_flag_inexact, status ); |
| 972 | #else |
| 973 | float_raise(float_flag_overflow | float_flag_inexact, status); |
| 974 | #endif |
| 975 | return packFloat64( zSign, 0x7FF, - ( roundIncrement == 0 )); |
| 976 | } |
| 977 | if ( zExp < 0 ) { |
| 978 | if (status->flush_to_zero) { |
| 979 | //float_raise(float_flag_output_denormal, status); |
| 980 | return packFloat64(zSign, 0, 0); |
| 981 | } |
| 982 | isTiny = |
| 983 | (status->float_detect_tininess |
| 984 | == float_tininess_before_rounding) |
| 985 | || ( zExp < -1 ) |
| 986 | || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) ); |
| 987 | #ifdef SOFTFLOAT_68K |
| 988 | if ( isTiny ) { |
| 989 | float_raise( float_flag_underflow, status ); |
| 990 | saveFloat64Internal( zSign, zExp, zSig, status ); |
| 991 | } |
| 992 | #endif |
no test coverage detected