| 1945 | *----------------------------------------------------------------------------*/ |
| 1946 | |
| 1947 | float32 floatx80_to_float32(floatx80 a, float_status *status) |
| 1948 | { |
| 1949 | flag aSign; |
| 1950 | int32_t aExp; |
| 1951 | uint64_t aSig; |
| 1952 | |
| 1953 | aSig = extractFloatx80Frac( a ); |
| 1954 | aExp = extractFloatx80Exp( a ); |
| 1955 | aSign = extractFloatx80Sign( a ); |
| 1956 | if ( aExp == 0x7FFF ) { |
| 1957 | if ( (uint64_t) ( aSig<<1 ) ) { |
| 1958 | return commonNaNToFloat32(floatx80ToCommonNaN(a, status)); |
| 1959 | } |
| 1960 | return packFloat32( aSign, 0xFF, 0 ); |
| 1961 | } |
| 1962 | #ifdef SOFTFLOAT_68K |
| 1963 | if ( aExp == 0 ) { |
| 1964 | if ( aSig == 0) return packFloat32( aSign, 0, 0 ); |
| 1965 | normalizeFloatx80Subnormal( aSig, &aExp, &aSig ); |
| 1966 | } |
| 1967 | shift64RightJamming( aSig, 33, &aSig ); |
| 1968 | aExp -= 0x3F81; |
| 1969 | #else |
| 1970 | shift64RightJamming( aSig, 33, &aSig ); |
| 1971 | if ( aExp || aSig ) aExp -= 0x3F81; |
| 1972 | #endif |
| 1973 | return roundAndPackFloat32(aSign, aExp, (uint32_t)aSig, status); |
| 1974 | |
| 1975 | } |
| 1976 | |
| 1977 | /*---------------------------------------------------------------------------- |
| 1978 | | Returns the result of converting the extended double-precision floating- |