aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING.txt10
-rw-r--r--README.html10
-rw-r--r--README.md14
-rw-r--r--README.txt4
-rw-r--r--build/Linux-386-GCC/Makefile60
-rw-r--r--build/Linux-386-GCC/platform.h10
-rw-r--r--build/Linux-386-SSE2-GCC/Makefile60
-rw-r--r--build/Linux-386-SSE2-GCC/platform.h10
-rw-r--r--build/Linux-x86_64-GCC/Makefile64
-rw-r--r--build/Linux-x86_64-GCC/platform.h10
-rw-r--r--build/Win32-MinGW/Makefile60
-rw-r--r--build/Win32-MinGW/platform.h10
-rw-r--r--build/Win32-SSE2-MinGW/Makefile60
-rw-r--r--build/Win32-SSE2-MinGW/platform.h10
-rw-r--r--build/Win64-MinGW-w64/Makefile64
-rw-r--r--build/Win64-MinGW-w64/platform.h10
-rw-r--r--build/template-FAST_INT64/Makefile64
-rw-r--r--build/template-FAST_INT64/platform.h10
-rw-r--r--build/template-not-FAST_INT64/Makefile60
-rw-r--r--build/template-not-FAST_INT64/platform.h10
-rw-r--r--doc/SoftFloat-history.html31
-rw-r--r--doc/SoftFloat-source.html99
-rw-r--r--doc/SoftFloat.html145
-rw-r--r--source/8086-SSE/extF80M_isSignalingNaN.c2
-rw-r--r--source/8086-SSE/f128M_isSignalingNaN.c2
-rw-r--r--source/8086-SSE/s_commonNaNToExtF80M.c2
-rw-r--r--source/8086-SSE/s_commonNaNToExtF80UI.c2
-rw-r--r--source/8086-SSE/s_commonNaNToF128M.c2
-rw-r--r--source/8086-SSE/s_commonNaNToF128UI.c2
-rw-r--r--source/8086-SSE/s_commonNaNToF16UI.c51
-rw-r--r--source/8086-SSE/s_commonNaNToF32UI.c2
-rw-r--r--source/8086-SSE/s_commonNaNToF64UI.c2
-rw-r--r--source/8086-SSE/s_extF80MToCommonNaN.c2
-rw-r--r--source/8086-SSE/s_extF80UIToCommonNaN.c2
-rw-r--r--source/8086-SSE/s_f128MToCommonNaN.c2
-rw-r--r--source/8086-SSE/s_f128UIToCommonNaN.c2
-rw-r--r--source/8086-SSE/s_f16UIToCommonNaN.c59
-rw-r--r--source/8086-SSE/s_f32UIToCommonNaN.c2
-rw-r--r--source/8086-SSE/s_f64UIToCommonNaN.c2
-rw-r--r--source/8086-SSE/s_propagateNaNExtF80M.c2
-rw-r--r--source/8086-SSE/s_propagateNaNExtF80UI.c2
-rw-r--r--source/8086-SSE/s_propagateNaNF128M.c2
-rw-r--r--source/8086-SSE/s_propagateNaNF128UI.c2
-rw-r--r--source/8086-SSE/s_propagateNaNF16UI.c63
-rw-r--r--source/8086-SSE/s_propagateNaNF32UI.c2
-rw-r--r--source/8086-SSE/s_propagateNaNF64UI.c2
-rw-r--r--source/8086-SSE/softfloat_raiseFlags.c2
-rw-r--r--source/8086-SSE/specialize.h41
-rw-r--r--source/8086/extF80M_isSignalingNaN.c2
-rw-r--r--source/8086/f128M_isSignalingNaN.c2
-rw-r--r--source/8086/s_commonNaNToExtF80M.c2
-rw-r--r--source/8086/s_commonNaNToExtF80UI.c2
-rw-r--r--source/8086/s_commonNaNToF128M.c2
-rw-r--r--source/8086/s_commonNaNToF128UI.c2
-rw-r--r--source/8086/s_commonNaNToF16UI.c51
-rw-r--r--source/8086/s_commonNaNToF32UI.c2
-rw-r--r--source/8086/s_commonNaNToF64UI.c2
-rw-r--r--source/8086/s_extF80MToCommonNaN.c2
-rw-r--r--source/8086/s_extF80UIToCommonNaN.c2
-rw-r--r--source/8086/s_f128MToCommonNaN.c2
-rw-r--r--source/8086/s_f128UIToCommonNaN.c2
-rw-r--r--source/8086/s_f16UIToCommonNaN.c59
-rw-r--r--source/8086/s_f32UIToCommonNaN.c2
-rw-r--r--source/8086/s_f64UIToCommonNaN.c2
-rw-r--r--source/8086/s_propagateNaNExtF80M.c2
-rw-r--r--source/8086/s_propagateNaNExtF80UI.c2
-rw-r--r--source/8086/s_propagateNaNF128M.c2
-rw-r--r--source/8086/s_propagateNaNF128UI.c2
-rw-r--r--source/8086/s_propagateNaNF16UI.c84
-rw-r--r--source/8086/s_propagateNaNF32UI.c2
-rw-r--r--source/8086/s_propagateNaNF64UI.c2
-rw-r--r--source/8086/softfloat_raiseFlags.c2
-rw-r--r--source/8086/specialize.h41
-rw-r--r--source/RISCV/extF80M_isSignalingNaN.c2
-rw-r--r--source/RISCV/f128M_isSignalingNaN.c2
-rw-r--r--source/RISCV/s_commonNaNToExtF80M.c2
-rw-r--r--source/RISCV/s_commonNaNToExtF80UI.c2
-rw-r--r--source/RISCV/s_commonNaNToF128M.c2
-rw-r--r--source/RISCV/s_commonNaNToF128UI.c2
-rw-r--r--source/RISCV/s_commonNaNToF16UI.c1
-rw-r--r--source/RISCV/s_f16UIToCommonNaN.c1
-rw-r--r--source/RISCV/s_propagateNaNExtF80M.c2
-rw-r--r--source/RISCV/s_propagateNaNExtF80UI.c2
-rw-r--r--source/RISCV/s_propagateNaNF128M.c2
-rw-r--r--source/RISCV/s_propagateNaNF128UI.c2
-rw-r--r--source/RISCV/s_propagateNaNF16UI.c58
-rw-r--r--source/RISCV/s_propagateNaNF32UI.c2
-rw-r--r--source/RISCV/s_propagateNaNF64UI.c2
-rw-r--r--source/RISCV/softfloat_raiseFlags.c2
-rw-r--r--source/RISCV/specialize.h63
-rw-r--r--source/extF80M_add.c2
-rw-r--r--source/extF80M_div.c14
-rw-r--r--source/extF80M_eq.c2
-rw-r--r--source/extF80M_eq_signaling.c2
-rw-r--r--source/extF80M_le.c2
-rw-r--r--source/extF80M_le_quiet.c2
-rw-r--r--source/extF80M_lt.c2
-rw-r--r--source/extF80M_lt_quiet.c2
-rw-r--r--source/extF80M_mul.c2
-rw-r--r--source/extF80M_rem.c2
-rw-r--r--source/extF80M_roundToInt.c2
-rw-r--r--source/extF80M_sqrt.c2
-rw-r--r--source/extF80M_sub.c2
-rw-r--r--source/extF80M_to_f128M.c2
-rw-r--r--source/extF80M_to_f16.c112
-rw-r--r--source/extF80M_to_f32.c10
-rw-r--r--source/extF80M_to_f64.c12
-rw-r--r--source/extF80M_to_i32.c4
-rw-r--r--source/extF80M_to_i32_r_minMag.c2
-rw-r--r--source/extF80M_to_i64.c2
-rw-r--r--source/extF80M_to_i64_r_minMag.c2
-rw-r--r--source/extF80M_to_ui32.c4
-rw-r--r--source/extF80M_to_ui32_r_minMag.c2
-rw-r--r--source/extF80M_to_ui64.c2
-rw-r--r--source/extF80M_to_ui64_r_minMag.c2
-rw-r--r--source/extF80_add.c2
-rw-r--r--source/extF80_div.c2
-rw-r--r--source/extF80_eq.c2
-rw-r--r--source/extF80_eq_signaling.c2
-rw-r--r--source/extF80_isSignalingNaN.c2
-rw-r--r--source/extF80_le.c2
-rw-r--r--source/extF80_le_quiet.c2
-rw-r--r--source/extF80_lt.c2
-rw-r--r--source/extF80_lt_quiet.c2
-rw-r--r--source/extF80_mul.c2
-rw-r--r--source/extF80_rem.c8
-rw-r--r--source/extF80_roundToInt.c2
-rw-r--r--source/extF80_sqrt.c10
-rw-r--r--source/extF80_sub.c2
-rw-r--r--source/extF80_to_f128.c16
-rw-r--r--source/extF80_to_f16.c96
-rw-r--r--source/extF80_to_f32.c16
-rw-r--r--source/extF80_to_f64.c16
-rw-r--r--source/extF80_to_i32.c4
-rw-r--r--source/extF80_to_i32_r_minMag.c2
-rw-r--r--source/extF80_to_i64.c2
-rw-r--r--source/extF80_to_i64_r_minMag.c2
-rw-r--r--source/extF80_to_ui32.c4
-rw-r--r--source/extF80_to_ui32_r_minMag.c2
-rw-r--r--source/extF80_to_ui64.c2
-rw-r--r--source/extF80_to_ui64_r_minMag.c2
-rw-r--r--source/f128M_add.c2
-rw-r--r--source/f128M_div.c2
-rw-r--r--source/f128M_eq.c2
-rw-r--r--source/f128M_eq_signaling.c2
-rw-r--r--source/f128M_le.c2
-rw-r--r--source/f128M_le_quiet.c2
-rw-r--r--source/f128M_lt.c2
-rw-r--r--source/f128M_lt_quiet.c2
-rw-r--r--source/f128M_mul.c14
-rw-r--r--source/f128M_mulAdd.c2
-rw-r--r--source/f128M_rem.c2
-rw-r--r--source/f128M_roundToInt.c2
-rw-r--r--source/f128M_sqrt.c2
-rw-r--r--source/f128M_sub.c2
-rw-r--r--source/f128M_to_extF80M.c2
-rw-r--r--source/f128M_to_f16.c113
-rw-r--r--source/f128M_to_f32.c30
-rw-r--r--source/f128M_to_f64.c34
-rw-r--r--source/f128M_to_i32.c4
-rw-r--r--source/f128M_to_i32_r_minMag.c2
-rw-r--r--source/f128M_to_i64.c2
-rw-r--r--source/f128M_to_i64_r_minMag.c2
-rw-r--r--source/f128M_to_ui32.c4
-rw-r--r--source/f128M_to_ui32_r_minMag.c2
-rw-r--r--source/f128M_to_ui64.c2
-rw-r--r--source/f128M_to_ui64_r_minMag.c2
-rw-r--r--source/f128_add.c2
-rw-r--r--source/f128_div.c2
-rw-r--r--source/f128_eq.c2
-rw-r--r--source/f128_eq_signaling.c2
-rw-r--r--source/f128_isSignalingNaN.c2
-rw-r--r--source/f128_le.c2
-rw-r--r--source/f128_le_quiet.c2
-rw-r--r--source/f128_lt.c2
-rw-r--r--source/f128_lt_quiet.c2
-rw-r--r--source/f128_mul.c2
-rw-r--r--source/f128_mulAdd.c2
-rw-r--r--source/f128_rem.c8
-rw-r--r--source/f128_roundToInt.c2
-rw-r--r--source/f128_sqrt.c12
-rw-r--r--source/f128_sub.c2
-rw-r--r--source/f128_to_extF80.c42
-rw-r--r--source/f128_to_f16.c95
-rw-r--r--source/f128_to_f32.c30
-rw-r--r--source/f128_to_f64.c34
-rw-r--r--source/f128_to_i32.c4
-rw-r--r--source/f128_to_i32_r_minMag.c2
-rw-r--r--source/f128_to_i64.c2
-rw-r--r--source/f128_to_i64_r_minMag.c2
-rw-r--r--source/f128_to_ui32.c4
-rw-r--r--source/f128_to_ui32_r_minMag.c2
-rw-r--r--source/f128_to_ui64.c2
-rw-r--r--source/f128_to_ui64_r_minMag.c2
-rw-r--r--source/f16_add.c70
-rw-r--r--source/f16_div.c186
-rw-r--r--source/f16_eq.c66
-rw-r--r--source/f16_eq_signaling.c61
-rw-r--r--source/f16_isSignalingNaN.c51
-rw-r--r--source/f16_le.c66
-rw-r--r--source/f16_le_quiet.c71
-rw-r--r--source/f16_lt.c66
-rw-r--r--source/f16_lt_quiet.c71
-rw-r--r--source/f16_mul.c140
-rw-r--r--source/f16_mulAdd.c60
-rw-r--r--source/f16_rem.c171
-rw-r--r--source/f16_roundToInt.c111
-rw-r--r--source/f16_sqrt.c136
-rw-r--r--source/f16_sub.c70
-rw-r--r--source/f16_to_extF80.c101
-rw-r--r--source/f16_to_extF80M.c111
-rw-r--r--source/f16_to_f128.c96
-rw-r--r--source/f16_to_f128M.c112
-rw-r--r--source/f16_to_f32.c93
-rw-r--r--source/f16_to_f64.c93
-rw-r--r--source/f16_to_i32.c87
-rw-r--r--source/f16_to_i32_r_minMag.c88
-rw-r--r--source/f16_to_i64.c87
-rw-r--r--source/f16_to_i64_r_minMag.c88
-rw-r--r--source/f16_to_ui32.c84
-rw-r--r--source/f16_to_ui32_r_minMag.c87
-rw-r--r--source/f16_to_ui64.c84
-rw-r--r--source/f16_to_ui64_r_minMag.c87
-rw-r--r--source/f32_add.c22
-rw-r--r--source/f32_div.c2
-rw-r--r--source/f32_eq.c2
-rw-r--r--source/f32_eq_signaling.c2
-rw-r--r--source/f32_isSignalingNaN.c2
-rw-r--r--source/f32_le.c2
-rw-r--r--source/f32_le_quiet.c2
-rw-r--r--source/f32_lt.c2
-rw-r--r--source/f32_lt_quiet.c2
-rw-r--r--source/f32_mul.c20
-rw-r--r--source/f32_mulAdd.c2
-rw-r--r--source/f32_rem.c2
-rw-r--r--source/f32_roundToInt.c2
-rw-r--r--source/f32_sqrt.c10
-rw-r--r--source/f32_sub.c22
-rw-r--r--source/f32_to_extF80.c28
-rw-r--r--source/f32_to_extF80M.c36
-rw-r--r--source/f32_to_f128.c28
-rw-r--r--source/f32_to_f128M.c36
-rw-r--r--source/f32_to_f16.c88
-rw-r--r--source/f32_to_f64.c28
-rw-r--r--source/f32_to_i32.c4
-rw-r--r--source/f32_to_i32_r_minMag.c2
-rw-r--r--source/f32_to_i64.c2
-rw-r--r--source/f32_to_i64_r_minMag.c2
-rw-r--r--source/f32_to_ui32.c4
-rw-r--r--source/f32_to_ui32_r_minMag.c2
-rw-r--r--source/f32_to_ui64.c2
-rw-r--r--source/f32_to_ui64_r_minMag.c2
-rw-r--r--source/f64_add.c2
-rw-r--r--source/f64_div.c2
-rw-r--r--source/f64_eq.c2
-rw-r--r--source/f64_eq_signaling.c2
-rw-r--r--source/f64_isSignalingNaN.c2
-rw-r--r--source/f64_le.c2
-rw-r--r--source/f64_le_quiet.c2
-rw-r--r--source/f64_lt.c2
-rw-r--r--source/f64_lt_quiet.c2
-rw-r--r--source/f64_mul.c2
-rw-r--r--source/f64_mulAdd.c2
-rw-r--r--source/f64_rem.c2
-rw-r--r--source/f64_roundToInt.c2
-rw-r--r--source/f64_sqrt.c2
-rw-r--r--source/f64_sub.c2
-rw-r--r--source/f64_to_extF80.c28
-rw-r--r--source/f64_to_extF80M.c28
-rw-r--r--source/f64_to_f128.c34
-rw-r--r--source/f64_to_f128M.c22
-rw-r--r--source/f64_to_f16.c88
-rw-r--r--source/f64_to_f32.c28
-rw-r--r--source/f64_to_i32.c4
-rw-r--r--source/f64_to_i32_r_minMag.c2
-rw-r--r--source/f64_to_i64.c2
-rw-r--r--source/f64_to_i64_r_minMag.c2
-rw-r--r--source/f64_to_ui32.c4
-rw-r--r--source/f64_to_ui32_r_minMag.c2
-rw-r--r--source/f64_to_ui64.c2
-rw-r--r--source/f64_to_ui64_r_minMag.c2
-rw-r--r--source/i32_to_extF80.c14
-rw-r--r--source/i32_to_extF80M.c14
-rw-r--r--source/i32_to_f128.c12
-rw-r--r--source/i32_to_f128M.c14
-rw-r--r--source/i32_to_f16.c71
-rw-r--r--source/i32_to_f32.c2
-rw-r--r--source/i32_to_f64.c12
-rw-r--r--source/i64_to_extF80.c14
-rw-r--r--source/i64_to_extF80M.c14
-rw-r--r--source/i64_to_f128.c18
-rw-r--r--source/i64_to_f128M.c20
-rw-r--r--source/i64_to_f16.c70
-rw-r--r--source/i64_to_f32.c24
-rw-r--r--source/i64_to_f64.c2
-rw-r--r--source/include/internals.h38
-rw-r--r--source/include/primitiveTypes.h2
-rw-r--r--source/include/primitives.h291
-rw-r--r--source/include/softfloat.h64
-rw-r--r--source/include/softfloat_types.h19
-rw-r--r--source/s_add128.c2
-rw-r--r--source/s_add256M.c6
-rw-r--r--source/s_addCarryM.c6
-rw-r--r--source/s_addComplCarryM.c6
-rw-r--r--source/s_addExtF80M.c2
-rw-r--r--source/s_addF128M.c2
-rw-r--r--source/s_addM.c6
-rw-r--r--source/s_addMagsExtF80.c2
-rw-r--r--source/s_addMagsF128.c2
-rw-r--r--source/s_addMagsF16.c178
-rw-r--r--source/s_addMagsF32.c39
-rw-r--r--source/s_addMagsF64.c45
-rw-r--r--source/s_approxRecip32_1.c33
-rw-r--r--source/s_approxRecipSqrt32_1.c34
-rw-r--r--source/s_approxRecipSqrt_1Ks.c49
-rw-r--r--source/s_approxRecip_1Ks.c49
-rw-r--r--source/s_compare128M.c2
-rw-r--r--source/s_compare96M.c2
-rw-r--r--source/s_compareNonnormExtF80M.c2
-rw-r--r--source/s_countLeadingZeros16.c60
-rw-r--r--source/s_countLeadingZeros32.c2
-rw-r--r--source/s_countLeadingZeros64.c2
-rw-r--r--source/s_countLeadingZeros8.c2
-rw-r--r--source/s_eq128.c2
-rw-r--r--source/s_invalidExtF80M.c2
-rw-r--r--source/s_invalidF128M.c2
-rw-r--r--source/s_isNaNF128M.c8
-rw-r--r--source/s_le128.c2
-rw-r--r--source/s_lt128.c2
-rw-r--r--source/s_mul128By32.c2
-rw-r--r--source/s_mul128MTo256M.c22
-rw-r--r--source/s_mul128To256M.c2
-rw-r--r--source/s_mul64ByShifted32To128.c2
-rw-r--r--source/s_mul64To128.c2
-rw-r--r--source/s_mul64To128M.c2
-rw-r--r--source/s_mulAddF128.c59
-rw-r--r--source/s_mulAddF128M.c12
-rw-r--r--source/s_mulAddF16.c226
-rw-r--r--source/s_mulAddF32.c46
-rw-r--r--source/s_mulAddF64.c60
-rw-r--r--source/s_negXM.c2
-rw-r--r--source/s_normExtF80SigM.c14
-rw-r--r--source/s_normRoundPackMToExtF80M.c22
-rw-r--r--source/s_normRoundPackMToF128M.c22
-rw-r--r--source/s_normRoundPackToExtF80.c16
-rw-r--r--source/s_normRoundPackToF128.c21
-rw-r--r--source/s_normRoundPackToF16.c58
-rw-r--r--source/s_normRoundPackToF32.c18
-rw-r--r--source/s_normRoundPackToF64.c18
-rw-r--r--source/s_normSubnormalExtF80Sig.c14
-rw-r--r--source/s_normSubnormalF128Sig.c26
-rw-r--r--source/s_normSubnormalF128SigM.c20
-rw-r--r--source/s_normSubnormalF16Sig.c52
-rw-r--r--source/s_normSubnormalF32Sig.c14
-rw-r--r--source/s_normSubnormalF64Sig.c14
-rw-r--r--source/s_remStepMBy32.c17
-rw-r--r--source/s_roundPackMToExtF80M.c2
-rw-r--r--source/s_roundPackMToF128M.c2
-rw-r--r--source/s_roundPackMToI64.c2
-rw-r--r--source/s_roundPackMToUI64.c2
-rw-r--r--source/s_roundPackToExtF80.c2
-rw-r--r--source/s_roundPackToF128.c2
-rw-r--r--source/s_roundPackToF16.c91
-rw-r--r--source/s_roundPackToF32.c10
-rw-r--r--source/s_roundPackToF64.c9
-rw-r--r--source/s_roundPackToI32.c16
-rw-r--r--source/s_roundPackToI64.c2
-rw-r--r--source/s_roundPackToUI32.c16
-rw-r--r--source/s_roundPackToUI64.c2
-rw-r--r--source/s_shiftLeftM.c40
-rw-r--r--source/s_shiftNormSigF128M.c14
-rw-r--r--source/s_shiftRightJam128.c24
-rw-r--r--source/s_shiftRightJam128Extra.c28
-rw-r--r--source/s_shiftRightJam256M.c60
-rw-r--r--source/s_shiftRightJam32.c9
-rw-r--r--source/s_shiftRightJam64.c9
-rw-r--r--source/s_shiftRightJam64Extra.c14
-rw-r--r--source/s_shiftRightJamM.c46
-rw-r--r--source/s_shiftRightM.c40
-rw-r--r--source/s_shortShiftLeft128.c10
-rw-r--r--source/s_shortShiftLeft64To96M.c10
-rw-r--r--source/s_shortShiftLeftM.c16
-rw-r--r--source/s_shortShiftRight128.c10
-rw-r--r--source/s_shortShiftRightExtendM.c14
-rw-r--r--source/s_shortShiftRightJam128.c16
-rw-r--r--source/s_shortShiftRightJam128Extra.c16
-rw-r--r--source/s_shortShiftRightJam64.c8
-rw-r--r--source/s_shortShiftRightJam64Extra.c10
-rw-r--r--source/s_shortShiftRightJamM.c18
-rw-r--r--source/s_shortShiftRightM.c16
-rw-r--r--source/s_sub128.c2
-rw-r--r--source/s_sub1XM.c2
-rw-r--r--source/s_sub256M.c2
-rw-r--r--source/s_subM.c2
-rw-r--r--source/s_subMagsExtF80.c8
-rw-r--r--source/s_subMagsF128.c8
-rw-r--r--source/s_subMagsF16.c182
-rw-r--r--source/s_subMagsF32.c128
-rw-r--r--source/s_subMagsF64.c120
-rw-r--r--source/s_tryPropagateNaNExtF80M.c2
-rw-r--r--source/s_tryPropagateNaNF128M.c2
-rw-r--r--source/softfloat_state.c18
-rw-r--r--source/ui32_to_extF80.c14
-rw-r--r--source/ui32_to_extF80M.c14
-rw-r--r--source/ui32_to_f128.c12
-rw-r--r--source/ui32_to_f128M.c14
-rw-r--r--source/ui32_to_f16.c65
-rw-r--r--source/ui32_to_f32.c2
-rw-r--r--source/ui32_to_f64.c13
-rw-r--r--source/ui64_to_extF80.c14
-rw-r--r--source/ui64_to_extF80M.c14
-rw-r--r--source/ui64_to_f128.c18
-rw-r--r--source/ui64_to_f128M.c21
-rw-r--r--source/ui64_to_f16.c64
-rw-r--r--source/ui64_to_f32.c22
-rw-r--r--source/ui64_to_f64.c2
416 files changed, 7535 insertions, 1670 deletions
diff --git a/COPYING.txt b/COPYING.txt
index 869e6da..d718ab6 100644
--- a/COPYING.txt
+++ b/COPYING.txt
@@ -1,14 +1,14 @@
-License for Berkeley SoftFloat Release 3a
+License for Berkeley SoftFloat Release 3b
John R. Hauser
-2015 October 23
+2016 July 22
-The following applies to the whole of SoftFloat Release 3a as well as to
+The following applies to the whole of SoftFloat Release 3b as well as to
each source file individually.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
-California. All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
diff --git a/README.html b/README.html
index ec64db7..ea7bbd3 100644
--- a/README.html
+++ b/README.html
@@ -7,11 +7,11 @@
<BODY>
-<H1>Package Overview for Berkeley SoftFloat Release 3a</H1>
+<H1>Package Overview for Berkeley SoftFloat Release 3b</H1>
<P>
John R. Hauser<BR>
-2015 October 23<BR>
+2016 July 22<BR>
</P>
<P>
@@ -29,15 +29,15 @@ The SoftFloat package is documented in the following files in the
<BLOCKQUOTE>
<TABLE>
<TR>
-<TD><A HREF="doc/SoftFloat.html"><CODE>SoftFloat.html</CODE></A></TD>
+<TD><A HREF="doc/SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A></TD>
<TD>Documentation for using the SoftFloat functions.</TD>
</TR>
<TR>
-<TD><A HREF="doc/SoftFloat-source.html"><CODE>SoftFloat-source.html</CODE></A></TD>
+<TD><A HREF="doc/SoftFloat-source.html"><NOBR><CODE>SoftFloat-source.html</CODE></NOBR></A></TD>
<TD>Documentation for building SoftFloat.</TD>
</TR>
<TR>
-<TD><A HREF="doc/SoftFloat-history.html"><CODE>SoftFloat-history.html</CODE></A><CODE>&nbsp;&nbsp;&nbsp;</CODE></TD>
+<TD><A HREF="doc/SoftFloat-history.html"><NOBR><CODE>SoftFloat-history.html</CODE></A><CODE>&nbsp;&nbsp;&nbsp;</CODE></NOBR></TD>
<TD>History of the major changes to SoftFloat.</TD>
</TR>
</TABLE>
diff --git a/README.md b/README.md
index 3a28440..246a6e7 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@
-Package Overview for Berkeley SoftFloat Release 3a
+Package Overview for Berkeley SoftFloat Release 3b
==================================================
John R. Hauser<br>
-2015 October 23
+2016 July 22
Berkeley SoftFloat is a software implementation of binary floating-point
-that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
-is distributed in the form of C source code. Building the SoftFloat sources
+that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
+is distributed in the form of C source code. Building the SoftFloat sources
generates a library file (typically `softfloat.a` or `libsoftfloat.a`)
containing the floating-point subroutines.
@@ -16,9 +16,9 @@ containing the floating-point subroutines.
The SoftFloat package is documented in the following files in the `doc`
subdirectory:
-* [SoftFloat.html](http://www.jhauser.us/arithmetic/SoftFloat-3a/doc/SoftFloat.html) Documentation for using the SoftFloat functions.
-* [SoftFloat-source.html](http://www.jhauser.us/arithmetic/SoftFloat-3a/doc/SoftFloat-source.html) Documentation for building SoftFloat.
-* [SoftFloat-history.html](http://www.jhauser.us/arithmetic/SoftFloat-3a/doc/SoftFloat-history.html) History of the major changes to SoftFloat.
+* [SoftFloat.html](http://www.jhauser.us/arithmetic/SoftFloat-3b/doc/SoftFloat.html) Documentation for using the SoftFloat functions.
+* [SoftFloat-source.html](http://www.jhauser.us/arithmetic/SoftFloat-3b/doc/SoftFloat-source.html) Documentation for building SoftFloat.
+* [SoftFloat-history.html](http://www.jhauser.us/arithmetic/SoftFloat-3b/doc/SoftFloat-history.html) History of the major changes to SoftFloat.
Other files in the package comprise the source code for SoftFloat.
diff --git a/README.txt b/README.txt
index 0011b11..25fd181 100644
--- a/README.txt
+++ b/README.txt
@@ -1,8 +1,8 @@
-Package Overview for Berkeley SoftFloat Release 3a
+Package Overview for Berkeley SoftFloat Release 3b
John R. Hauser
-2015 October 23
+2016 July 22
Berkeley SoftFloat is a software implementation of binary floating-point
that conforms to the IEEE Standard for Floating-Point Arithmetic. SoftFloat
diff --git a/build/Linux-386-GCC/Makefile b/build/Linux-386-GCC/Makefile
index e21067e..a1be83e 100644
--- a/build/Linux-386-GCC/Makefile
+++ b/build/Linux-386-GCC/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile is part of the SoftFloat IEEE Floating-Point Arithmetic
-# Package, Release 3a, by John R. Hauser.
+# Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -34,10 +34,11 @@
#
#=============================================================================
-SOURCE_DIR = ../../source
-SPECIALIZE_TYPE = 8086
+SOURCE_DIR ?= ../../source
+SPECIALIZE_TYPE ?= 8086
-SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+SOFTFLOAT_OPTS ?= \
+ -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -66,6 +67,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJamM$(OBJ) \
s_shiftRightM$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_addM$(OBJ) \
@@ -76,12 +78,17 @@ OBJS_PRIMITIVES = \
s_subM$(OBJ) \
s_mul64To128M$(OBJ) \
s_mul128MTo256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
s_remStepMBy32$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -102,6 +109,12 @@ OBJS_OTHERS = \
s_roundPackMToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackMToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -130,22 +143,53 @@ OBJS_OTHERS = \
s_addF128M$(OBJ) \
s_mulAddF128M$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -154,6 +198,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80M$(OBJ) \
f32_to_f128M$(OBJ) \
@@ -180,6 +225,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80M$(OBJ) \
f64_to_f128M$(OBJ) \
@@ -206,6 +252,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -230,6 +277,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_f64$(OBJ) \
f128M_to_extF80M$(OBJ) \
diff --git a/build/Linux-386-GCC/platform.h b/build/Linux-386-GCC/platform.h
index b3e4720..fadcc25 100644
--- a/build/Linux-386-GCC/platform.h
+++ b/build/Linux-386-GCC/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,5 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
#define INLINE extern inline
+#endif
diff --git a/build/Linux-386-SSE2-GCC/Makefile b/build/Linux-386-SSE2-GCC/Makefile
index b0435c5..0b9a0aa 100644
--- a/build/Linux-386-SSE2-GCC/Makefile
+++ b/build/Linux-386-SSE2-GCC/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile is part of the SoftFloat IEEE Floating-Point Arithmetic
-# Package, Release 3a, by John R. Hauser.
+# Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -34,10 +34,11 @@
#
#=============================================================================
-SOURCE_DIR = ../../source
-SPECIALIZE_TYPE = 8086-SSE
+SOURCE_DIR ?= ../../source
+SPECIALIZE_TYPE ?= 8086-SSE
-SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+SOFTFLOAT_OPTS ?= \
+ -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -66,6 +67,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJamM$(OBJ) \
s_shiftRightM$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_addM$(OBJ) \
@@ -76,12 +78,17 @@ OBJS_PRIMITIVES = \
s_subM$(OBJ) \
s_mul64To128M$(OBJ) \
s_mul128MTo256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
s_remStepMBy32$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -102,6 +109,12 @@ OBJS_OTHERS = \
s_roundPackMToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackMToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -130,22 +143,53 @@ OBJS_OTHERS = \
s_addF128M$(OBJ) \
s_mulAddF128M$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -154,6 +198,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80M$(OBJ) \
f32_to_f128M$(OBJ) \
@@ -180,6 +225,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80M$(OBJ) \
f64_to_f128M$(OBJ) \
@@ -206,6 +252,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -230,6 +277,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_f64$(OBJ) \
f128M_to_extF80M$(OBJ) \
diff --git a/build/Linux-386-SSE2-GCC/platform.h b/build/Linux-386-SSE2-GCC/platform.h
index b3e4720..fadcc25 100644
--- a/build/Linux-386-SSE2-GCC/platform.h
+++ b/build/Linux-386-SSE2-GCC/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,5 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
#define INLINE extern inline
+#endif
diff --git a/build/Linux-x86_64-GCC/Makefile b/build/Linux-x86_64-GCC/Makefile
index 9996139..9c9fd7b 100644
--- a/build/Linux-x86_64-GCC/Makefile
+++ b/build/Linux-x86_64-GCC/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile is part of the SoftFloat IEEE Floating-Point Arithmetic
-# Package, Release 3a, by John R. Hauser.
+# Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -34,10 +34,11 @@
#
#=============================================================================
-SOURCE_DIR = ../../source
-SPECIALIZE_TYPE = 8086-SSE
+SOURCE_DIR ?= ../../source
+SPECIALIZE_TYPE ?= 8086-SSE
-SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+SOFTFLOAT_OPTS ?= \
+ -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -69,6 +70,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJam128Extra$(OBJ) \
s_shiftRightJam256M$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_add128$(OBJ) \
@@ -79,11 +81,16 @@ OBJS_PRIMITIVES = \
s_mul64To128$(OBJ) \
s_mul128By32$(OBJ) \
s_mul128To256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -104,6 +111,12 @@ OBJS_OTHERS = \
s_roundPackToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -128,30 +141,63 @@ OBJS_OTHERS = \
s_subMagsF128$(OBJ) \
s_mulAddF128$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -160,6 +206,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80$(OBJ) \
f32_to_extF80M$(OBJ) \
@@ -188,6 +235,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80$(OBJ) \
f64_to_extF80M$(OBJ) \
@@ -216,6 +264,7 @@ OBJS_OTHERS = \
extF80_to_ui64_r_minMag$(OBJ) \
extF80_to_i32_r_minMag$(OBJ) \
extF80_to_i64_r_minMag$(OBJ) \
+ extF80_to_f16$(OBJ) \
extF80_to_f32$(OBJ) \
extF80_to_f64$(OBJ) \
extF80_to_f128$(OBJ) \
@@ -241,6 +290,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -265,6 +315,7 @@ OBJS_OTHERS = \
f128_to_ui64_r_minMag$(OBJ) \
f128_to_i32_r_minMag$(OBJ) \
f128_to_i64_r_minMag$(OBJ) \
+ f128_to_f16$(OBJ) \
f128_to_f32$(OBJ) \
f128_to_extF80$(OBJ) \
f128_to_f64$(OBJ) \
@@ -291,6 +342,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_extF80M$(OBJ) \
f128M_to_f64$(OBJ) \
diff --git a/build/Linux-x86_64-GCC/platform.h b/build/Linux-x86_64-GCC/platform.h
index b3e4720..fadcc25 100644
--- a/build/Linux-x86_64-GCC/platform.h
+++ b/build/Linux-x86_64-GCC/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,5 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
#define INLINE extern inline
+#endif
diff --git a/build/Win32-MinGW/Makefile b/build/Win32-MinGW/Makefile
index e21067e..a1be83e 100644
--- a/build/Win32-MinGW/Makefile
+++ b/build/Win32-MinGW/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile is part of the SoftFloat IEEE Floating-Point Arithmetic
-# Package, Release 3a, by John R. Hauser.
+# Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -34,10 +34,11 @@
#
#=============================================================================
-SOURCE_DIR = ../../source
-SPECIALIZE_TYPE = 8086
+SOURCE_DIR ?= ../../source
+SPECIALIZE_TYPE ?= 8086
-SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+SOFTFLOAT_OPTS ?= \
+ -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -66,6 +67,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJamM$(OBJ) \
s_shiftRightM$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_addM$(OBJ) \
@@ -76,12 +78,17 @@ OBJS_PRIMITIVES = \
s_subM$(OBJ) \
s_mul64To128M$(OBJ) \
s_mul128MTo256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
s_remStepMBy32$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -102,6 +109,12 @@ OBJS_OTHERS = \
s_roundPackMToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackMToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -130,22 +143,53 @@ OBJS_OTHERS = \
s_addF128M$(OBJ) \
s_mulAddF128M$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -154,6 +198,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80M$(OBJ) \
f32_to_f128M$(OBJ) \
@@ -180,6 +225,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80M$(OBJ) \
f64_to_f128M$(OBJ) \
@@ -206,6 +252,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -230,6 +277,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_f64$(OBJ) \
f128M_to_extF80M$(OBJ) \
diff --git a/build/Win32-MinGW/platform.h b/build/Win32-MinGW/platform.h
index b3e4720..fadcc25 100644
--- a/build/Win32-MinGW/platform.h
+++ b/build/Win32-MinGW/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,5 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
#define INLINE extern inline
+#endif
diff --git a/build/Win32-SSE2-MinGW/Makefile b/build/Win32-SSE2-MinGW/Makefile
index b0435c5..0b9a0aa 100644
--- a/build/Win32-SSE2-MinGW/Makefile
+++ b/build/Win32-SSE2-MinGW/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile is part of the SoftFloat IEEE Floating-Point Arithmetic
-# Package, Release 3a, by John R. Hauser.
+# Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -34,10 +34,11 @@
#
#=============================================================================
-SOURCE_DIR = ../../source
-SPECIALIZE_TYPE = 8086-SSE
+SOURCE_DIR ?= ../../source
+SPECIALIZE_TYPE ?= 8086-SSE
-SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+SOFTFLOAT_OPTS ?= \
+ -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -66,6 +67,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJamM$(OBJ) \
s_shiftRightM$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_addM$(OBJ) \
@@ -76,12 +78,17 @@ OBJS_PRIMITIVES = \
s_subM$(OBJ) \
s_mul64To128M$(OBJ) \
s_mul128MTo256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
s_remStepMBy32$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -102,6 +109,12 @@ OBJS_OTHERS = \
s_roundPackMToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackMToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -130,22 +143,53 @@ OBJS_OTHERS = \
s_addF128M$(OBJ) \
s_mulAddF128M$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -154,6 +198,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80M$(OBJ) \
f32_to_f128M$(OBJ) \
@@ -180,6 +225,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80M$(OBJ) \
f64_to_f128M$(OBJ) \
@@ -206,6 +252,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -230,6 +277,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_f64$(OBJ) \
f128M_to_extF80M$(OBJ) \
diff --git a/build/Win32-SSE2-MinGW/platform.h b/build/Win32-SSE2-MinGW/platform.h
index b3e4720..fadcc25 100644
--- a/build/Win32-SSE2-MinGW/platform.h
+++ b/build/Win32-SSE2-MinGW/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,5 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
#define INLINE extern inline
+#endif
diff --git a/build/Win64-MinGW-w64/Makefile b/build/Win64-MinGW-w64/Makefile
index 1ca74af..145c03f 100644
--- a/build/Win64-MinGW-w64/Makefile
+++ b/build/Win64-MinGW-w64/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile is part of the SoftFloat IEEE Floating-Point Arithmetic
-# Package, Release 3a, by John R. Hauser.
+# Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -34,10 +34,11 @@
#
#=============================================================================
-SOURCE_DIR = ../../source
-SPECIALIZE_TYPE = 8086-SSE
+SOURCE_DIR ?= ../../source
+SPECIALIZE_TYPE ?= 8086-SSE
-SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+SOFTFLOAT_OPTS ?= \
+ -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -69,6 +70,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJam128Extra$(OBJ) \
s_shiftRightJam256M$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_add128$(OBJ) \
@@ -79,11 +81,16 @@ OBJS_PRIMITIVES = \
s_mul64To128$(OBJ) \
s_mul128By32$(OBJ) \
s_mul128To256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -104,6 +111,12 @@ OBJS_OTHERS = \
s_roundPackToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -128,30 +141,63 @@ OBJS_OTHERS = \
s_subMagsF128$(OBJ) \
s_mulAddF128$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -160,6 +206,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80$(OBJ) \
f32_to_extF80M$(OBJ) \
@@ -188,6 +235,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80$(OBJ) \
f64_to_extF80M$(OBJ) \
@@ -216,6 +264,7 @@ OBJS_OTHERS = \
extF80_to_ui64_r_minMag$(OBJ) \
extF80_to_i32_r_minMag$(OBJ) \
extF80_to_i64_r_minMag$(OBJ) \
+ extF80_to_f16$(OBJ) \
extF80_to_f32$(OBJ) \
extF80_to_f64$(OBJ) \
extF80_to_f128$(OBJ) \
@@ -241,6 +290,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -265,6 +315,7 @@ OBJS_OTHERS = \
f128_to_ui64_r_minMag$(OBJ) \
f128_to_i32_r_minMag$(OBJ) \
f128_to_i64_r_minMag$(OBJ) \
+ f128_to_f16$(OBJ) \
f128_to_f32$(OBJ) \
f128_to_extF80$(OBJ) \
f128_to_f64$(OBJ) \
@@ -291,6 +342,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_extF80M$(OBJ) \
f128M_to_f64$(OBJ) \
diff --git a/build/Win64-MinGW-w64/platform.h b/build/Win64-MinGW-w64/platform.h
index b3e4720..fadcc25 100644
--- a/build/Win64-MinGW-w64/platform.h
+++ b/build/Win64-MinGW-w64/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,5 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
#define INLINE extern inline
+#endif
diff --git a/build/template-FAST_INT64/Makefile b/build/template-FAST_INT64/Makefile
index 0f836f9..34673a3 100644
--- a/build/template-FAST_INT64/Makefile
+++ b/build/template-FAST_INT64/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile template is part of the SoftFloat IEEE Floating-Point
-# Arithmetic Package, Release 3a, by John R. Hauser.
+# Arithmetic Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -36,10 +36,11 @@
# Edit lines marked with `==>'. See "SoftFloat-source.html".
-==> SOURCE_DIR = ../../source
-==> SPECIALIZE_TYPE = 8086
+==> SOURCE_DIR ?= ../../source
+==> SPECIALIZE_TYPE ?= 8086
-==> SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+==> SOFTFLOAT_OPTS ?= \
+==> -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
==> DELETE = rm -f
==> C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -70,6 +71,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJam128Extra$(OBJ) \
s_shiftRightJam256M$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_add128$(OBJ) \
@@ -80,11 +82,16 @@ OBJS_PRIMITIVES = \
s_mul64To128$(OBJ) \
s_mul128By32$(OBJ) \
s_mul128To256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -105,6 +112,12 @@ OBJS_OTHERS = \
s_roundPackToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -129,30 +142,63 @@ OBJS_OTHERS = \
s_subMagsF128$(OBJ) \
s_mulAddF128$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -161,6 +207,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80$(OBJ) \
f32_to_extF80M$(OBJ) \
@@ -189,6 +236,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80$(OBJ) \
f64_to_extF80M$(OBJ) \
@@ -217,6 +265,7 @@ OBJS_OTHERS = \
extF80_to_ui64_r_minMag$(OBJ) \
extF80_to_i32_r_minMag$(OBJ) \
extF80_to_i64_r_minMag$(OBJ) \
+ extF80_to_f16$(OBJ) \
extF80_to_f32$(OBJ) \
extF80_to_f64$(OBJ) \
extF80_to_f128$(OBJ) \
@@ -242,6 +291,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -266,6 +316,7 @@ OBJS_OTHERS = \
f128_to_ui64_r_minMag$(OBJ) \
f128_to_i32_r_minMag$(OBJ) \
f128_to_i64_r_minMag$(OBJ) \
+ f128_to_f16$(OBJ) \
f128_to_f32$(OBJ) \
f128_to_extF80$(OBJ) \
f128_to_f64$(OBJ) \
@@ -292,6 +343,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_extF80M$(OBJ) \
f128M_to_f64$(OBJ) \
diff --git a/build/template-FAST_INT64/platform.h b/build/template-FAST_INT64/platform.h
index f4832d2..2aef589 100644
--- a/build/template-FAST_INT64/platform.h
+++ b/build/template-FAST_INT64/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header template is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,3 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*----------------------------------------------------------------------------*/
==> #define INLINE inline
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+==> #define THREAD_LOCAL _Thread_local
+
diff --git a/build/template-not-FAST_INT64/Makefile b/build/template-not-FAST_INT64/Makefile
index 3500fdb..2bdc946 100644
--- a/build/template-not-FAST_INT64/Makefile
+++ b/build/template-not-FAST_INT64/Makefile
@@ -2,10 +2,10 @@
#=============================================================================
#
# This Makefile template is part of the SoftFloat IEEE Floating-Point
-# Arithmetic Package, Release 3a, by John R. Hauser.
+# Arithmetic Package, Release 3b, by John R. Hauser.
#
-# Copyright 2011, 2012, 2013, 2014 The Regents of the University of
-# California. All rights reserved.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University
+# of California. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -36,10 +36,11 @@
# Edit lines marked with `==>'. See "SoftFloat-source.html".
-==> SOURCE_DIR = ../../source
-==> SPECIALIZE_TYPE = 8086
+==> SOURCE_DIR ?= ../../source
+==> SPECIALIZE_TYPE ?= 8086
-==> SOFTFLOAT_OPTS = -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV64TO32
+==> SOFTFLOAT_OPTS ?= \
+==> -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32
==> DELETE = rm -f
==> C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
@@ -66,6 +67,7 @@ OBJS_PRIMITIVES = \
s_shiftRightJamM$(OBJ) \
s_shiftRightM$(OBJ) \
s_countLeadingZeros8$(OBJ) \
+ s_countLeadingZeros16$(OBJ) \
s_countLeadingZeros32$(OBJ) \
s_countLeadingZeros64$(OBJ) \
s_addM$(OBJ) \
@@ -76,12 +78,17 @@ OBJS_PRIMITIVES = \
s_subM$(OBJ) \
s_mul64To128M$(OBJ) \
s_mul128MTo256M$(OBJ) \
+ s_approxRecip_1Ks$(OBJ) \
s_approxRecip32_1$(OBJ) \
+ s_approxRecipSqrt_1Ks$(OBJ) \
s_approxRecipSqrt32_1$(OBJ) \
s_remStepMBy32$(OBJ) \
OBJS_SPECIALIZE = \
softfloat_raiseFlags$(OBJ) \
+ s_f16UIToCommonNaN$(OBJ) \
+ s_commonNaNToF16UI$(OBJ) \
+ s_propagateNaNF16UI$(OBJ) \
s_f32UIToCommonNaN$(OBJ) \
s_commonNaNToF32UI$(OBJ) \
s_propagateNaNF32UI$(OBJ) \
@@ -102,6 +109,12 @@ OBJS_OTHERS = \
s_roundPackMToUI64$(OBJ) \
s_roundPackToI32$(OBJ) \
s_roundPackMToI64$(OBJ) \
+ s_normSubnormalF16Sig$(OBJ) \
+ s_roundPackToF16$(OBJ) \
+ s_normRoundPackToF16$(OBJ) \
+ s_addMagsF16$(OBJ) \
+ s_subMagsF16$(OBJ) \
+ s_mulAddF16$(OBJ) \
s_normSubnormalF32Sig$(OBJ) \
s_roundPackToF32$(OBJ) \
s_normRoundPackToF32$(OBJ) \
@@ -130,22 +143,53 @@ OBJS_OTHERS = \
s_addF128M$(OBJ) \
s_mulAddF128M$(OBJ) \
softfloat_state$(OBJ) \
+ ui32_to_f16$(OBJ) \
ui32_to_f32$(OBJ) \
ui32_to_f64$(OBJ) \
ui32_to_extF80M$(OBJ) \
ui32_to_f128M$(OBJ) \
+ ui64_to_f16$(OBJ) \
ui64_to_f32$(OBJ) \
ui64_to_f64$(OBJ) \
ui64_to_extF80M$(OBJ) \
ui64_to_f128M$(OBJ) \
+ i32_to_f16$(OBJ) \
i32_to_f32$(OBJ) \
i32_to_f64$(OBJ) \
i32_to_extF80M$(OBJ) \
i32_to_f128M$(OBJ) \
+ i64_to_f16$(OBJ) \
i64_to_f32$(OBJ) \
i64_to_f64$(OBJ) \
i64_to_extF80M$(OBJ) \
i64_to_f128M$(OBJ) \
+ f16_to_ui32$(OBJ) \
+ f16_to_ui64$(OBJ) \
+ f16_to_i32$(OBJ) \
+ f16_to_i64$(OBJ) \
+ f16_to_ui32_r_minMag$(OBJ) \
+ f16_to_ui64_r_minMag$(OBJ) \
+ f16_to_i32_r_minMag$(OBJ) \
+ f16_to_i64_r_minMag$(OBJ) \
+ f16_to_f32$(OBJ) \
+ f16_to_f64$(OBJ) \
+ f16_to_extF80M$(OBJ) \
+ f16_to_f128M$(OBJ) \
+ f16_roundToInt$(OBJ) \
+ f16_add$(OBJ) \
+ f16_sub$(OBJ) \
+ f16_mul$(OBJ) \
+ f16_mulAdd$(OBJ) \
+ f16_div$(OBJ) \
+ f16_rem$(OBJ) \
+ f16_sqrt$(OBJ) \
+ f16_eq$(OBJ) \
+ f16_le$(OBJ) \
+ f16_lt$(OBJ) \
+ f16_eq_signaling$(OBJ) \
+ f16_le_quiet$(OBJ) \
+ f16_lt_quiet$(OBJ) \
+ f16_isSignalingNaN$(OBJ) \
f32_to_ui32$(OBJ) \
f32_to_ui64$(OBJ) \
f32_to_i32$(OBJ) \
@@ -154,6 +198,7 @@ OBJS_OTHERS = \
f32_to_ui64_r_minMag$(OBJ) \
f32_to_i32_r_minMag$(OBJ) \
f32_to_i64_r_minMag$(OBJ) \
+ f32_to_f16$(OBJ) \
f32_to_f64$(OBJ) \
f32_to_extF80M$(OBJ) \
f32_to_f128M$(OBJ) \
@@ -180,6 +225,7 @@ OBJS_OTHERS = \
f64_to_ui64_r_minMag$(OBJ) \
f64_to_i32_r_minMag$(OBJ) \
f64_to_i64_r_minMag$(OBJ) \
+ f64_to_f16$(OBJ) \
f64_to_f32$(OBJ) \
f64_to_extF80M$(OBJ) \
f64_to_f128M$(OBJ) \
@@ -206,6 +252,7 @@ OBJS_OTHERS = \
extF80M_to_ui64_r_minMag$(OBJ) \
extF80M_to_i32_r_minMag$(OBJ) \
extF80M_to_i64_r_minMag$(OBJ) \
+ extF80M_to_f16$(OBJ) \
extF80M_to_f32$(OBJ) \
extF80M_to_f64$(OBJ) \
extF80M_to_f128M$(OBJ) \
@@ -230,6 +277,7 @@ OBJS_OTHERS = \
f128M_to_ui64_r_minMag$(OBJ) \
f128M_to_i32_r_minMag$(OBJ) \
f128M_to_i64_r_minMag$(OBJ) \
+ f128M_to_f16$(OBJ) \
f128M_to_f32$(OBJ) \
f128M_to_f64$(OBJ) \
f128M_to_extF80M$(OBJ) \
diff --git a/build/template-not-FAST_INT64/platform.h b/build/template-not-FAST_INT64/platform.h
index f4832d2..2aef589 100644
--- a/build/template-not-FAST_INT64/platform.h
+++ b/build/template-not-FAST_INT64/platform.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header template is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,3 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*----------------------------------------------------------------------------*/
==> #define INLINE inline
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+==> #define THREAD_LOCAL _Thread_local
+
diff --git a/doc/SoftFloat-history.html b/doc/SoftFloat-history.html
index 08cab39..f5f7c91 100644
--- a/doc/SoftFloat-history.html
+++ b/doc/SoftFloat-history.html
@@ -7,14 +7,41 @@
<BODY>
-<H1>History of Berkeley SoftFloat, to Release 3a</H1>
+<H1>History of Berkeley SoftFloat, to Release 3b</H1>
<P>
John R. Hauser<BR>
-2015 October 23<BR>
+2016 July 22<BR>
</P>
+<H3>Release 3b (2016 July)</H3>
+
+<UL>
+
+<LI>
+Implemented the common <NOBR>16-bit</NOBR> &ldquo;half-precision&rdquo;
+floating-point format (<CODE>float16_t</CODE>).
+
+<LI>
+Made the integer values returned on invalid conversions to integer formats
+be determined by the port-specific specialization instead of being the same for
+all ports.
+
+<LI>
+Added preprocessor macro <CODE>THREAD_LOCAL</CODE> to allow the floating-point
+state (modes and exception flags) to be made per-thread.
+
+<LI>
+Modified the provided Makefiles to allow some options to be overridden from the
+<CODE>make</CODE> command.
+
+<LI>
+Made other minor improvements.
+
+</UL>
+
+
<H3>Release 3a (2015 October)</H3>
<UL>
diff --git a/doc/SoftFloat-source.html b/doc/SoftFloat-source.html
index dff77aa..b69565f 100644
--- a/doc/SoftFloat-source.html
+++ b/doc/SoftFloat-source.html
@@ -7,11 +7,11 @@
<BODY>
-<H1>Berkeley SoftFloat Release 3a: Source Documentation</H1>
+<H1>Berkeley SoftFloat Release 3b: Source Documentation</H1>
<P>
John R. Hauser<BR>
-2015 October 23<BR>
+2016 July 22<BR>
</P>
@@ -53,7 +53,7 @@ This document gives information needed for compiling and/or porting Berkeley
SoftFloat, a library of C functions implementing binary floating-point
conforming to the IEEE Standard for Floating-Point Arithmetic.
For basic documentation about SoftFloat refer to
-<A HREF="SoftFloat.html"><CODE>SoftFloat.html</CODE></A>.
+<A HREF="SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A>.
</P>
<P>
@@ -68,8 +68,8 @@ SoftFloat has been successfully compiled with the GNU C Compiler
<NOBR>Release 3</NOBR> of SoftFloat was a complete rewrite relative to
<NOBR>Release 2</NOBR> or earlier.
Changes to the interface of SoftFloat functions are documented in
-<A HREF="SoftFloat.html"><CODE>SoftFloat.html</CODE></A>.
-The current version of SoftFloat is <NOBR>Release 3a</NOBR>.
+<A HREF="SoftFloat.html"><NOBR><CODE>SoftFloat.html</CODE></NOBR></A>.
+The current version of SoftFloat is <NOBR>Release 3b</NOBR>.
</P>
@@ -114,10 +114,10 @@ SoftFloat&rsquo;s dependence on these headers is detailed later in
The SoftFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
<NOBR>Release 3</NOBR> of SoftFloat was a completely new implementation
supplanting earlier releases.
-The project to create <NOBR>Release 3</NOBR> (and <NOBR>now 3a</NOBR>) was done
-in the employ of the University of California, Berkeley, within the Department
-of Electrical Engineering and Computer Sciences, first for the Parallel
-Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
+The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3b</NOBR>) was
+done in the employ of the University of California, Berkeley, within the
+Department of Electrical Engineering and Computer Sciences, first for the
+Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
The work was officially overseen by Prof. Krste Asanovic, with funding provided
by these sources:
<BLOCKQUOTE>
@@ -148,12 +148,12 @@ Oracle, and Samsung.
</P>
<P>
-The following applies to the whole of SoftFloat <NOBR>Release 3a</NOBR> as well
+The following applies to the whole of SoftFloat <NOBR>Release 3b</NOBR> as well
as to each source file individually.
</P>
<P>
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California.
All rights reserved.
</P>
@@ -236,9 +236,9 @@ processors.
The files in directory <CODE>8086</CODE> give floating-point behavior
consistent solely with Intel&rsquo;s older, 8087-derived floating-point, while
those in <NOBR><CODE>8086-SSE</CODE></NOBR> update the behavior of the
-non-extended formats (<CODE>float32_t</CODE>, <CODE>float64_t</CODE>, and
-<CODE>float128_t</CODE>) to mirror Intel&rsquo;s more recent Streaming SIMD
-Extensions (SSE) and other compatible extensions.
+non-extended formats (<CODE>float16_t</CODE>, <CODE>float32_t</CODE>,
+<CODE>float64_t</CODE>, and <CODE>float128_t</CODE>) to mirror Intel&rsquo;s
+more recent Streaming SIMD Extensions (SSE) and other compatible extensions.
If other specializations are attempted, these would be expected to be other
subdirectories of <CODE>source</CODE> alongside <CODE>8086</CODE> and
<NOBR><CODE>8086-SSE</CODE></NOBR>.
@@ -370,9 +370,12 @@ what (if anything) special happens when exceptions are raised;
<LI>
how signaling NaNs are distinguished from quiet NaNs;
<LI>
-the default generated quiet NaNs; and
+the default generated quiet NaNs;
<LI>
-how NaNs are propagated from function inputs to output.
+how NaNs are propagated from function inputs to output; and
+<LI>
+the integer results returned when conversions to integer type raise the
+<I>invalid</I> exception.
</UL>
</P>
@@ -418,6 +421,13 @@ For very small microprocessors whose buses and registers are <NOBR>8-bit</NOBR>
or <NOBR>16-bit</NOBR> in size, this macro should usually not be defined.
Whether this macro should be defined for a <NOBR>32-bit</NOBR> processor may
depend on the target machine and the applications that will use SoftFloat.
+<DT><CODE>SOFTFLOAT_FAST_DIV32TO16</CODE>
+<DD>
+Can be defined to indicate that the target&rsquo;s division operator
+<NOBR>in C</NOBR> (written as <CODE>/</CODE>) is reasonably efficient for
+dividing a <NOBR>32-bit</NOBR> unsigned integer by a <NOBR>16-bit</NOBR>
+unsigned integer.
+Setting this macro may affect the performance of function <CODE>f16_div</CODE>.
<DT><CODE>SOFTFLOAT_FAST_DIV64TO32</CODE>
<DD>
Can be defined to indicate that the target&rsquo;s division operator
@@ -425,7 +435,7 @@ Can be defined to indicate that the target&rsquo;s division operator
dividing a <NOBR>64-bit</NOBR> unsigned integer by a <NOBR>32-bit</NOBR>
unsigned integer.
Setting this macro may affect the performance of division, remainder, and
-square root operations.
+square root operations other than <CODE>f16_div</CODE>.
<DT><CODE>INLINE_LEVEL</CODE>
<DD>
Can be defined to an integer to determine the degree of inlining requested of
@@ -443,26 +453,41 @@ inlined.
If macro <CODE>INLINE_LEVEL</CODE> is defined with a value of 1 or higher, this
macro must be defined; otherwise, this macro is ignored and need not be
defined.
-For some compilers, this macro can be defined as the single keyword
+For compilers that conform to the C Standard&rsquo;s rules for inline
+functions, this macro can be defined as the single keyword <CODE>inline</CODE>.
+For other compilers that follow a convention pre-dating the standardization of
+<CODE>inline</CODE>, this macro may need to be defined to <CODE>extern</CODE>
<CODE>inline</CODE>.
-Historically, the <CODE>gcc</CODE> compiler has required that this macro be
-defined to <CODE>extern</CODE> <CODE>inline</CODE>.
+<DT><CODE>THREAD_LOCAL</CODE>
+<DD>
+Can be defined to a sequence of tokens that, when appearing at the start of a
+variable declaration, indicates to the C compiler that the variable is
+<I>per-thread</I>, meaning that each execution thread gets its own separate
+instance of the variable.
+This macro is used in header <CODE>softfloat.h</CODE> in the declarations of
+variables <CODE>softfloat_roundingMode</CODE>,
+<CODE>softfloat_detectTininess</CODE>, <CODE>extF80_roundingPrecision</CODE>,
+and <CODE>softfloat_exceptionFlags</CODE>.
+If macro <CODE>THREAD_LOCAL</CODE> is left undefined, these variables will
+default to being ordinary global variables.
+Depending on the compiler, possible valid definitions of this macro include
+<CODE>_Thread_local</CODE> and <CODE>__thread</CODE>.
</DL>
</BLOCKQUOTE>
</P>
<P>
-Following the usual custom <NOBR>for C</NOBR>, for the first three macros (all
-except <CODE>INLINE_LEVEL</CODE> and <CODE>INLINE</CODE>), the content of any
-definition is irrelevant;
+Following the usual custom <NOBR>for C</NOBR>, for the first four macros (all
+except <CODE>INLINE_LEVEL</CODE>, <CODE>INLINE</CODE>, and
+<CODE>THREAD_LOCAL</CODE>), the content of any definition is irrelevant;
what matters is a macro&rsquo;s effect on <CODE>#ifdef</CODE> directives.
</P>
<P>
-It is recommended that any definitions of macros <CODE>LITTLEENDIAN</CODE> and
-<CODE>INLINE</CODE> be made in a build target&rsquo;s <CODE>platform.h</CODE>
-header file, because these macros are expected to be determined inflexibly by
-the target machine and compiler.
+It is recommended that any definitions of macros <CODE>LITTLEENDIAN</CODE>,
+<CODE>INLINE</CODE>, and <CODE>THREAD_LOCAL</CODE> be made in a build
+target&rsquo;s <CODE>platform.h</CODE> header file, because these macros are
+expected to be determined inflexibly by the target machine and compiler.
The other three macros control optimization and might be better located in the
target&rsquo;s Makefile (or its equivalent).
</P>
@@ -496,7 +521,7 @@ underlying arithmetic operations upon which many of SoftFloat&rsquo;s
floating-point functions are ultimately built.
The SoftFloat sources include implementations of all of these functions/macros,
written as standard C code, so a complete and correct SoftFloat library can be
-built using only the supplied code for all functions.
+created using only the supplied code for all functions.
However, for many targets, SoftFloat&rsquo;s performance can be improved by
substituting target-specific implementations of some of the functions/macros
declared in <CODE>primitives.h</CODE>.
@@ -505,8 +530,8 @@ declared in <CODE>primitives.h</CODE>.
<P>
For example, <CODE>primitives.h</CODE> declares a function called
<CODE>softfloat_countLeadingZeros32</CODE> that takes an unsigned
-<NOBR>32-bit</NOBR> integer as an argument and returns the maximal number of
-the integer&rsquo;s most-significant bits that are all zeros.
+<NOBR>32-bit</NOBR> integer as an argument and returns the number of the
+integer&rsquo;s most-significant bits that are zeros.
While the SoftFloat sources include an implementation of this function written
in <NOBR>standard C</NOBR>, many processors can perform this same function
directly in only one or two machine instructions.
@@ -534,7 +559,7 @@ where <NOBR><CODE>&lt;function-name&gt;</CODE></NOBR> is the name of the
function.
This technically defines <NOBR><CODE>&lt;function-name&gt;</CODE></NOBR> as a
macro, but one that resolves to the same name, which may then be a function.
-(A preprocessor conforming to the C Standard must limit recursive macro
+(A preprocessor that conforms to the C Standard must limit recursive macro
expansion from being applied more than once.)
</P>
@@ -546,7 +571,7 @@ SoftFloat can be tested using the <CODE>testsoftfloat</CODE> program by the
same author.
This program is part of the Berkeley TestFloat package available at the Web
page
-<A HREF="http://www.jhauser.us/arithmetic/TestFloat.html"><CODE>http://www.jhauser.us/arithmetic/TestFloat.html</CODE></A>.
+<A HREF="http://www.jhauser.us/arithmetic/TestFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/TestFloat.html</CODE></NOBR></A>.
The TestFloat package also has a program called <CODE>timesoftfloat</CODE> that
measures the speed of SoftFloat&rsquo;s floating-point functions.
</P>
@@ -566,10 +591,10 @@ As supplied, <CODE>softfloat.h</CODE> depends on another header,
<CODE>softfloat_types.h</CODE>, that is not intended for public use but which
must also be visible to the programmer&rsquo;s compiler.
<LI>
-More troubling, at the time <CODE>softfloat.h</CODE> is included in a C
-source file, macro <CODE>SOFTFLOAT_FAST_INT64</CODE> must be defined, or not
-defined, consistent with whether this macro was defined when the SoftFloat
-library was built.
+More troubling, at the time <CODE>softfloat.h</CODE> is included in a C source
+file, macros <CODE>SOFTFLOAT_FAST_INT64</CODE> and <CODE>THREAD_LOCAL</CODE>
+must be defined, or not defined, consistent with how these macro were defined
+when the SoftFloat library was built.
</UL>
In the situation that new programs may regularly <CODE>#include</CODE> header
file <CODE>softfloat.h</CODE>, it is recommended that a custom, self-contained
@@ -582,7 +607,7 @@ version of this header file be created that eliminates these issues.
<P>
At the time of this writing, the most up-to-date information about SoftFloat
and the latest release can be found at the Web page
-<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></A>.
+<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
</P>
diff --git a/doc/SoftFloat.html b/doc/SoftFloat.html
index 19176dc..b0ae66f 100644
--- a/doc/SoftFloat.html
+++ b/doc/SoftFloat.html
@@ -7,11 +7,11 @@
<BODY>
-<H1>Berkeley SoftFloat Release 3a: Library Interface</H1>
+<H1>Berkeley SoftFloat Release 3b: Library Interface</H1>
<P>
John R. Hauser<BR>
-2015 October 23<BR>
+2016 July 22<BR>
</P>
@@ -71,9 +71,10 @@ John R. Hauser<BR>
<P>
Berkeley SoftFloat is a software implementation of binary floating-point that
conforms to the IEEE Standard for Floating-Point Arithmetic.
-The current release supports four binary formats: <NOBR>32-bit</NOBR>
-single-precision, <NOBR>64-bit</NOBR> double-precision, <NOBR>80-bit</NOBR>
-double-extended-precision, and <NOBR>128-bit</NOBR> quadruple-precision.
+The current release supports five binary formats: <NOBR>16-bit</NOBR>
+half-precision, <NOBR>32-bit</NOBR> single-precision, <NOBR>64-bit</NOBR>
+double-precision, <NOBR>80-bit</NOBR> double-extended-precision, and
+<NOBR>128-bit</NOBR> quadruple-precision.
The following functions are supported for each format:
<UL>
<LI>
@@ -105,15 +106,19 @@ Information about the standard is available elsewhere.
</P>
<P>
-The current version of SoftFloat is <NOBR>Release 3a</NOBR>.
-The only difference between this version and the previous
-<NOBR>Release 3</NOBR> is the replacement of the license text supplied by the
-University of California.
+The current version of SoftFloat is <NOBR>Release 3b</NOBR>.
+This release differs from the previous <NOBR>Release 3a</NOBR> mainly in the
+addition of support for the <NOBR>16-bit</NOBR> half-precision format.
+Depending on the specific port of SoftFloat, this release may also change the
+result obtained when conversion of a floating-point number to an integer format
+overflows or is otherwise invalid.
+For more about the evolution of SoftFloat releases, see
+<A HREF="SoftFloat-history.html"><NOBR><CODE>SoftFloat-history.html</CODE></NOBR></A>.
</P>
<P>
-The functional interface of SoftFloat <NOBR>Release 3</NOBR> and afterward
-differs in many details from that of earlier releases.
+The functional interface of SoftFloat <NOBR>Release 3</NOBR> and later differs
+in many details from that of earlier releases.
For specifics of these differences, see <NOBR>section 9</NOBR> below,
<I>Changes from SoftFloat <NOBR>Release 2</NOBR></I>.
</P>
@@ -145,7 +150,7 @@ strictly required.
<P>
Most operations not required by the original 1985 version of the IEEE
Floating-Point Standard but added in the 2008 version are not yet supported in
-SoftFloat <NOBR>Release 3a</NOBR>.
+SoftFloat <NOBR>Release 3b</NOBR>.
</P>
@@ -155,10 +160,10 @@ SoftFloat <NOBR>Release 3a</NOBR>.
The SoftFloat package was written by me, <NOBR>John R.</NOBR> Hauser.
<NOBR>Release 3</NOBR> of SoftFloat was a completely new implementation
supplanting earlier releases.
-The project to create <NOBR>Release 3</NOBR> (and <NOBR>now 3a</NOBR>) was done
-in the employ of the University of California, Berkeley, within the Department
-of Electrical Engineering and Computer Sciences, first for the Parallel
-Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
+The project to create <NOBR>Release 3</NOBR> (now <NOBR>through 3b</NOBR>) was
+done in the employ of the University of California, Berkeley, within the
+Department of Electrical Engineering and Computer Sciences, first for the
+Parallel Computing Laboratory (Par Lab) and then for the ASPIRE Lab.
The work was officially overseen by Prof. Krste Asanovic, with funding provided
by these sources:
<BLOCKQUOTE>
@@ -189,12 +194,12 @@ Oracle, and Samsung.
</P>
<P>
-The following applies to the whole of SoftFloat <NOBR>Release 3a</NOBR> as well
+The following applies to the whole of SoftFloat <NOBR>Release 3b</NOBR> as well
as to each source file individually.
</P>
<P>
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California.
All rights reserved.
</P>
@@ -257,7 +262,7 @@ Header file <CODE>softfloat.h</CODE> depends on standard headers
<CODE>bool</CODE> and several integer types.
These standard headers have been part of the ISO C Standard Library since 1999.
With any recent compiler, they are likely to be supported, even if the compiler
-does not claim complete conformance to the ISO C Standard.
+does not claim complete conformance to the latest ISO C Standard.
For older or nonstandard compilers, a port of SoftFloat may have substitutes
for these headers.
Header <CODE>softfloat.h</CODE> depends only on the name <CODE>bool</CODE> from
@@ -273,6 +278,8 @@ int64_t
uint_fast8_t
uint_fast32_t
uint_fast64_t
+int_fast32_t
+int_fast64_t
</PRE>
</BLOCKQUOTE>
</P>
@@ -281,10 +288,14 @@ uint_fast64_t
<H3>4.2. Floating-Point Types</H3>
<P>
-The <CODE>softfloat.h</CODE> header defines four floating-point types:
+The <CODE>softfloat.h</CODE> header defines five floating-point types:
<BLOCKQUOTE>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
+<TD><CODE>float16_t</CODE></TD>
+<TD><NOBR>16-bit</NOBR> half-precision binary format</TD>
+</TR>
+<TR>
<TD><CODE>float32_t</CODE></TD>
<TD><NOBR>32-bit</NOBR> single-precision binary format</TD>
</TR>
@@ -304,8 +315,9 @@ Motorola format)</TD>
</TABLE>
</BLOCKQUOTE>
The non-extended types are each exactly the size specified:
-<NOBR>32 bits</NOBR> for <CODE>float32_t</CODE>, <NOBR>64 bits</NOBR> for
-<CODE>float64_t</CODE>, and <NOBR>128 bits</NOBR> for <CODE>float128_t</CODE>.
+<NOBR>16 bits</NOBR> for <CODE>float16_t</CODE>, <NOBR>32 bits</NOBR> for
+<CODE>float32_t</CODE>, <NOBR>64 bits</NOBR> for <CODE>float64_t</CODE>, and
+<NOBR>128 bits</NOBR> for <CODE>float128_t</CODE>.
Aside from these size requirements, the definitions of all these types may
differ for different ports of SoftFloat to specific systems.
A given port of SoftFloat may or may not define some of the floating-point
@@ -364,7 +376,7 @@ comparisons between two values in the same floating-point format.
<P>
The following operations required by the 2008 IEEE Floating-Point Standard are
-not supported in SoftFloat <NOBR>Release 3a</NOBR>:
+not supported in SoftFloat <NOBR>Release 3b</NOBR>:
<UL>
<LI>
<B>nextUp</B>, <B>nextDown</B>, <B>minNum</B>, <B>maxNum</B>, <B>minNumMag</B>,
@@ -492,14 +504,17 @@ prefix, and should reference only such names as are documented.
<H2>6. Mode Variables</H2>
<P>
-The following variables control rounding mode, underflow detection, and the
-<NOBR>80-bit</NOBR> extended format&rsquo;s rounding precision:
+The following global variables control rounding mode, underflow detection, and
+the <NOBR>80-bit</NOBR> extended format&rsquo;s rounding precision:
<BLOCKQUOTE>
<CODE>softfloat_roundingMode</CODE><BR>
<CODE>softfloat_detectTininess</CODE><BR>
<CODE>extF80_roundingPrecision</CODE>
</BLOCKQUOTE>
These mode variables are covered in the next several subsections.
+For some SoftFloat ports, these variables may be <I>per-thread</I> (declared
+<CODE>thread_local</CODE>), meaning that different execution threads have their
+own separate copies of the variables.
</P>
<H3>6.1. Rounding Mode</H3>
@@ -616,30 +631,36 @@ meaning no exceptions.
</P>
<P>
+For some SoftFloat ports, <CODE>softfloat_exceptionFlags</CODE> may be
+<I>per-thread</I> (declared <CODE>thread_local</CODE>), meaning that different
+execution threads have their own separate instances of it.
+</P>
+
+<P>
An individual exception flag can be cleared with the statement
<BLOCKQUOTE>
<CODE>softfloat_exceptionFlags &= ~softfloat_flag_&lt;<I>exception</I>&gt;;</CODE>
</BLOCKQUOTE>
where <CODE>&lt;<I>exception</I>&gt;</CODE> is the appropriate name.
-To raise a floating-point exception, function <CODE>softfloat_raise</CODE>
+To raise a floating-point exception, function <CODE>softfloat_raiseFlags</CODE>
should normally be used.
</P>
<P>
When SoftFloat detects an exception other than <I>inexact</I>, it calls
-<CODE>softfloat_raise</CODE>.
+<CODE>softfloat_raiseFlags</CODE>.
The default version of this function simply raises the corresponding exception
flags.
Particular ports of SoftFloat may support alternate behavior, such as exception
-traps, by modifying the default <CODE>softfloat_raise</CODE>.
-A program may also supply its own <CODE>softfloat_raise</CODE> function to
+traps, by modifying the default <CODE>softfloat_raiseFlags</CODE>.
+A program may also supply its own <CODE>softfloat_raiseFlags</CODE> function to
override the one from the SoftFloat library.
</P>
<P>
Because inexact results occur frequently under most circumstances (and thus are
hardly exceptional), SoftFloat does not ordinarily call
-<CODE>softfloat_raise</CODE> for <I>inexact</I> exceptions.
+<CODE>softfloat_raiseFlags</CODE> for <I>inexact</I> exceptions.
It does always raise the <I>inexact</I> exception flag as required.
</P>
@@ -652,6 +673,10 @@ a substitute for one of these abbreviations:
<BLOCKQUOTE>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
+<TD><CODE>f16</CODE></TD>
+<TD>indicates <CODE>float16_t</CODE>, passed by value</TD>
+</TR>
+<TR>
<TD><CODE>f32</CODE></TD>
<TD>indicates <CODE>float32_t</CODE>, passed by value</TD>
</TR>
@@ -752,24 +777,14 @@ otherwise, it will not be, even if the conversion is inexact.
</P>
<P>
-Conversions from floating-point to integer raise the <I>invalid</I> exception
-if the source value cannot be rounded to a representable integer of the desired
-size (32 or 64 bits).
-In such a circumstance, if the floating-point input is a NaN or if the
-conversion is to an unsigned integer type, the largest positive integer is
-returned;
-otherwise, the largest integer with the same sign as the input is returned.
-The functions that convert to integer types never raise the <I>overflow</I>
-exception.
-</P>
-
-<P>
-Note that, when converting to an unsigned integer type, if the <I>invalid</I>
-exception is raised because the input floating-point value would round to a
-negative integer, the value returned is the <EM>maximum positive unsigned
-integer</EM>.
-Zero is not returned when the <I>invalid</I> exception is raised, even when
-zero is the closest integer to the original floating-point value.
+A conversion from floating-point to integer format raises the <I>invalid</I>
+exception if the source value cannot be rounded to a representable integer of
+the desired size (32 or 64 bits).
+In such circumstances, the integer result returned is determined by the
+particular port of SoftFloat, although typically this value will be either the
+maximum or minimum value of the integer format.
+The functions that convert to integer types never raise the floating-point
+<I>overflow</I> exception.
</P>
<P>
@@ -884,11 +899,9 @@ SoftFloat implements fused multiply-add with functions
<BLOCKQUOTE>
<CODE>&lt;<I>float</I>&gt;_mulAdd</CODE>
</BLOCKQUOTE>
-Unlike other operations, fused multiple-add is supported only for the
-non-extended formats, <CODE>float32_t</CODE>, <CODE>float64_t</CODE>, and
-<CODE>float128_t</CODE>.
-No fused multiple-add function is currently provided for the
-<NOBR>80-bit</NOBR> double-extended-precision type, <CODE>extFloat80_t</CODE>.
+Unlike other operations, fused multiple-add is not supported for the
+<NOBR>80-bit</NOBR> double-extended-precision format,
+<CODE>extFloat80_t</CODE>.
</P>
<P>
@@ -971,8 +984,8 @@ no rounding.
Depending on the relative magnitudes of the operands, the remainder
functions can take considerably longer to execute than the other SoftFloat
functions.
-This is inherent in the remainder operation itself and is not a flaw in the
-SoftFloat implementation.
+This is an inherent characteristic of the remainder operation itself and is not
+a flaw in the SoftFloat implementation.
</P>
<H3>8.7. Round-to-Integer Functions</H3>
@@ -1103,14 +1116,14 @@ bool f128M_isSignalingNaN( const float128_t *<I>aPtr</I> );
SoftFloat provides a single function for raising floating-point exceptions:
<BLOCKQUOTE>
<PRE>
-void softfloat_raise( uint_fast8_t <I>exceptions</I> );
+void softfloat_raiseFlags( uint_fast8_t <I>exceptions</I> );
</PRE>
</BLOCKQUOTE>
The <CODE><I>exceptions</I></CODE> argument is a mask indicating the set of
exceptions to raise.
(See earlier section 7, <I>Exceptions and Exception Flags</I>.)
In addition to setting the specified exception flags in variable
-<CODE>softfloat_exceptionFlags</CODE>, the <CODE>softfloat_raise</CODE>
+<CODE>softfloat_exceptionFlags</CODE>, the <CODE>softfloat_raiseFlags</CODE>
function may cause a trap or abort appropriate for the current system.
</P>
@@ -1216,7 +1229,7 @@ have been renamed as follows:
</TR>
<TR>
<TD><CODE>float_raise</CODE></TD>
-<TD><CODE>softfloat_raise</CODE></TD>
+<TD><CODE>softfloat_raiseFlags</CODE></TD>
</TR>
</TABLE>
</BLOCKQUOTE>
@@ -1367,8 +1380,15 @@ all cases involving rounding.
<P>
<LI>
-Fused multiply-add functions have been added for the non-extended formats,
-<CODE>float32_t</CODE>, <CODE>float64_t</CODE>, and <CODE>float128_t</CODE>.
+Fused multiply-add functions have been added for all floating-point formats
+except <NOBR>80-bit</NOBR> double-extended-precision,
+<CODE>extFloat80_t</CODE>.
+</P>
+
+<P>
+<LI>
+As of <NOBR>Release 3b</NOBR>, <NOBR>16-bit</NOBR> half-precision,
+<CODE>float16_t</CODE>, is supported.
</P>
</UL>
@@ -1427,9 +1447,6 @@ Some loss of speed has been observed due to this change.
The following improvements are anticipated for future releases of SoftFloat:
<UL>
<LI>
-support for the common <NOBR>16-bit</NOBR> &ldquo;half-precision&rdquo;
-floating-point format;
-<LI>
more functions from the 2008 version of the IEEE Floating-Point Standard;
<LI>
consistent, defined behavior for non-canonical representations of extended
@@ -1445,7 +1462,7 @@ format <CODE>extFloat80_t</CODE> (discussed in <NOBR>section 4.4</NOBR>,
<P>
At the time of this writing, the most up-to-date information about SoftFloat
and the latest release can be found at the Web page
-<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></A>.
+<A HREF="http://www.jhauser.us/arithmetic/SoftFloat.html"><NOBR><CODE>http://www.jhauser.us/arithmetic/SoftFloat.html</CODE></NOBR></A>.
</P>
diff --git a/source/8086-SSE/extF80M_isSignalingNaN.c b/source/8086-SSE/extF80M_isSignalingNaN.c
index 4a05f54..be3dc40 100644
--- a/source/8086-SSE/extF80M_isSignalingNaN.c
+++ b/source/8086-SSE/extF80M_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/f128M_isSignalingNaN.c b/source/8086-SSE/f128M_isSignalingNaN.c
index 9ca5fea..6560615 100644
--- a/source/8086-SSE/f128M_isSignalingNaN.c
+++ b/source/8086-SSE/f128M_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_commonNaNToExtF80M.c b/source/8086-SSE/s_commonNaNToExtF80M.c
index cbccf1d..42e6adc 100644
--- a/source/8086-SSE/s_commonNaNToExtF80M.c
+++ b/source/8086-SSE/s_commonNaNToExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_commonNaNToExtF80UI.c b/source/8086-SSE/s_commonNaNToExtF80UI.c
index cea01d9..d88c3bf 100644
--- a/source/8086-SSE/s_commonNaNToExtF80UI.c
+++ b/source/8086-SSE/s_commonNaNToExtF80UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_commonNaNToF128M.c b/source/8086-SSE/s_commonNaNToF128M.c
index f54cd49..ec0301e 100644
--- a/source/8086-SSE/s_commonNaNToF128M.c
+++ b/source/8086-SSE/s_commonNaNToF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_commonNaNToF128UI.c b/source/8086-SSE/s_commonNaNToF128UI.c
index 64b9e0e..256b77b 100644
--- a/source/8086-SSE/s_commonNaNToF128UI.c
+++ b/source/8086-SSE/s_commonNaNToF128UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_commonNaNToF16UI.c b/source/8086-SSE/s_commonNaNToF16UI.c
new file mode 100644
index 0000000..15e6dae
--- /dev/null
+++ b/source/8086-SSE/s_commonNaNToF16UI.c
@@ -0,0 +1,51 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "specialize.h"
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
+{
+
+ return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
+
+}
+
diff --git a/source/8086-SSE/s_commonNaNToF32UI.c b/source/8086-SSE/s_commonNaNToF32UI.c
index 47557ce..39c8522 100644
--- a/source/8086-SSE/s_commonNaNToF32UI.c
+++ b/source/8086-SSE/s_commonNaNToF32UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_commonNaNToF64UI.c b/source/8086-SSE/s_commonNaNToF64UI.c
index 7fc5dfe..bdfb0d1 100644
--- a/source/8086-SSE/s_commonNaNToF64UI.c
+++ b/source/8086-SSE/s_commonNaNToF64UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_extF80MToCommonNaN.c b/source/8086-SSE/s_extF80MToCommonNaN.c
index 3a4c17e..476f17e 100644
--- a/source/8086-SSE/s_extF80MToCommonNaN.c
+++ b/source/8086-SSE/s_extF80MToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_extF80UIToCommonNaN.c b/source/8086-SSE/s_extF80UIToCommonNaN.c
index bae4aa7..dd63151 100644
--- a/source/8086-SSE/s_extF80UIToCommonNaN.c
+++ b/source/8086-SSE/s_extF80UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_f128MToCommonNaN.c b/source/8086-SSE/s_f128MToCommonNaN.c
index 76dd5c5..f080fd8 100644
--- a/source/8086-SSE/s_f128MToCommonNaN.c
+++ b/source/8086-SSE/s_f128MToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_f128UIToCommonNaN.c b/source/8086-SSE/s_f128UIToCommonNaN.c
index 750d22b..9c2ec2f 100644
--- a/source/8086-SSE/s_f128UIToCommonNaN.c
+++ b/source/8086-SSE/s_f128UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_f16UIToCommonNaN.c b/source/8086-SSE/s_f16UIToCommonNaN.c
new file mode 100644
index 0000000..0b5273c
--- /dev/null
+++ b/source/8086-SSE/s_f16UIToCommonNaN.c
@@ -0,0 +1,59 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
+{
+
+ if ( softfloat_isSigNaNF16UI( uiA ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ zPtr->sign = uiA>>15;
+ zPtr->v64 = (uint_fast64_t) uiA<<54;
+ zPtr->v0 = 0;
+
+}
+
diff --git a/source/8086-SSE/s_f32UIToCommonNaN.c b/source/8086-SSE/s_f32UIToCommonNaN.c
index 2bb28f8..0a14729 100644
--- a/source/8086-SSE/s_f32UIToCommonNaN.c
+++ b/source/8086-SSE/s_f32UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_f64UIToCommonNaN.c b/source/8086-SSE/s_f64UIToCommonNaN.c
index 4339ce9..bb9c2fa 100644
--- a/source/8086-SSE/s_f64UIToCommonNaN.c
+++ b/source/8086-SSE/s_f64UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_propagateNaNExtF80M.c b/source/8086-SSE/s_propagateNaNExtF80M.c
index 67d81ba..80b5897 100644
--- a/source/8086-SSE/s_propagateNaNExtF80M.c
+++ b/source/8086-SSE/s_propagateNaNExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_propagateNaNExtF80UI.c b/source/8086-SSE/s_propagateNaNExtF80UI.c
index 16f4251..3fc1d7a 100644
--- a/source/8086-SSE/s_propagateNaNExtF80UI.c
+++ b/source/8086-SSE/s_propagateNaNExtF80UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_propagateNaNF128M.c b/source/8086-SSE/s_propagateNaNF128M.c
index fff5503..cf0cf69 100644
--- a/source/8086-SSE/s_propagateNaNF128M.c
+++ b/source/8086-SSE/s_propagateNaNF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_propagateNaNF128UI.c b/source/8086-SSE/s_propagateNaNF128UI.c
index 6954505..d650365 100644
--- a/source/8086-SSE/s_propagateNaNF128UI.c
+++ b/source/8086-SSE/s_propagateNaNF128UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_propagateNaNF16UI.c b/source/8086-SSE/s_propagateNaNF16UI.c
new file mode 100644
index 0000000..7f88498
--- /dev/null
+++ b/source/8086-SSE/s_propagateNaNF16UI.c
@@ -0,0 +1,63 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ bool isSigNaNA;
+
+ isSigNaNA = softfloat_isSigNaNF16UI( uiA );
+ if ( isSigNaNA || softfloat_isSigNaNF16UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) return uiA | 0x0200;
+ }
+ return (isNaNF16UI( uiA ) ? uiA : uiB) | 0x0200;
+
+}
+
diff --git a/source/8086-SSE/s_propagateNaNF32UI.c b/source/8086-SSE/s_propagateNaNF32UI.c
index 010cef8..19c8654 100644
--- a/source/8086-SSE/s_propagateNaNF32UI.c
+++ b/source/8086-SSE/s_propagateNaNF32UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/s_propagateNaNF64UI.c b/source/8086-SSE/s_propagateNaNF64UI.c
index ca5b1bd..9186fdb 100644
--- a/source/8086-SSE/s_propagateNaNF64UI.c
+++ b/source/8086-SSE/s_propagateNaNF64UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/softfloat_raiseFlags.c b/source/8086-SSE/softfloat_raiseFlags.c
index 7b5ba25..5ba1502 100644
--- a/source/8086-SSE/softfloat_raiseFlags.c
+++ b/source/8086-SSE/softfloat_raiseFlags.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086-SSE/specialize.h b/source/8086-SSE/specialize.h
index 8a71e46..d2c6b22 100644
--- a/source/8086-SSE/specialize.h
+++ b/source/8086-SSE/specialize.h
@@ -2,7 +2,7 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -47,7 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define init_detectTininess softfloat_tininess_afterRounding
/*----------------------------------------------------------------------------
-| The values to return on conversions to 32-bit integer format that raise an
+| The values to return on conversions to 32-bit integer formats that raise an
| invalid exception.
*----------------------------------------------------------------------------*/
#define ui32_fromPosOverflow 0xFFFFFFFF
@@ -58,7 +58,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define i32_fromNaN 0x7FFFFFFF
/*----------------------------------------------------------------------------
-| The values to return on conversions to 64-bit integer format that raise an
+| The values to return on conversions to 64-bit integer formats that raise an
| invalid exception.
*----------------------------------------------------------------------------*/
#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
@@ -82,6 +82,41 @@ struct commonNaN {
};
/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 16-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF16UI 0xFE00
+
+/*----------------------------------------------------------------------------
+| Returns true when 16-bit unsigned integer `uiA' has the bit pattern of a
+| 16-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
+
+/*----------------------------------------------------------------------------
| The bit pattern for a default generated 32-bit floating-point NaN.
*----------------------------------------------------------------------------*/
#define defaultNaNF32UI 0xFFC00000
diff --git a/source/8086/extF80M_isSignalingNaN.c b/source/8086/extF80M_isSignalingNaN.c
index 4a05f54..be3dc40 100644
--- a/source/8086/extF80M_isSignalingNaN.c
+++ b/source/8086/extF80M_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/f128M_isSignalingNaN.c b/source/8086/f128M_isSignalingNaN.c
index 9ca5fea..6560615 100644
--- a/source/8086/f128M_isSignalingNaN.c
+++ b/source/8086/f128M_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_commonNaNToExtF80M.c b/source/8086/s_commonNaNToExtF80M.c
index cbccf1d..42e6adc 100644
--- a/source/8086/s_commonNaNToExtF80M.c
+++ b/source/8086/s_commonNaNToExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_commonNaNToExtF80UI.c b/source/8086/s_commonNaNToExtF80UI.c
index cea01d9..d88c3bf 100644
--- a/source/8086/s_commonNaNToExtF80UI.c
+++ b/source/8086/s_commonNaNToExtF80UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_commonNaNToF128M.c b/source/8086/s_commonNaNToF128M.c
index f54cd49..ec0301e 100644
--- a/source/8086/s_commonNaNToF128M.c
+++ b/source/8086/s_commonNaNToF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_commonNaNToF128UI.c b/source/8086/s_commonNaNToF128UI.c
index 64b9e0e..256b77b 100644
--- a/source/8086/s_commonNaNToF128UI.c
+++ b/source/8086/s_commonNaNToF128UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_commonNaNToF16UI.c b/source/8086/s_commonNaNToF16UI.c
new file mode 100644
index 0000000..15e6dae
--- /dev/null
+++ b/source/8086/s_commonNaNToF16UI.c
@@ -0,0 +1,51 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "specialize.h"
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
+{
+
+ return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
+
+}
+
diff --git a/source/8086/s_commonNaNToF32UI.c b/source/8086/s_commonNaNToF32UI.c
index 47557ce..39c8522 100644
--- a/source/8086/s_commonNaNToF32UI.c
+++ b/source/8086/s_commonNaNToF32UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_commonNaNToF64UI.c b/source/8086/s_commonNaNToF64UI.c
index 7fc5dfe..bdfb0d1 100644
--- a/source/8086/s_commonNaNToF64UI.c
+++ b/source/8086/s_commonNaNToF64UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_extF80MToCommonNaN.c b/source/8086/s_extF80MToCommonNaN.c
index 3a4c17e..476f17e 100644
--- a/source/8086/s_extF80MToCommonNaN.c
+++ b/source/8086/s_extF80MToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_extF80UIToCommonNaN.c b/source/8086/s_extF80UIToCommonNaN.c
index bae4aa7..dd63151 100644
--- a/source/8086/s_extF80UIToCommonNaN.c
+++ b/source/8086/s_extF80UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_f128MToCommonNaN.c b/source/8086/s_f128MToCommonNaN.c
index 76dd5c5..f080fd8 100644
--- a/source/8086/s_f128MToCommonNaN.c
+++ b/source/8086/s_f128MToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_f128UIToCommonNaN.c b/source/8086/s_f128UIToCommonNaN.c
index 750d22b..9c2ec2f 100644
--- a/source/8086/s_f128UIToCommonNaN.c
+++ b/source/8086/s_f128UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_f16UIToCommonNaN.c b/source/8086/s_f16UIToCommonNaN.c
new file mode 100644
index 0000000..0b5273c
--- /dev/null
+++ b/source/8086/s_f16UIToCommonNaN.c
@@ -0,0 +1,59 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
+{
+
+ if ( softfloat_isSigNaNF16UI( uiA ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ zPtr->sign = uiA>>15;
+ zPtr->v64 = (uint_fast64_t) uiA<<54;
+ zPtr->v0 = 0;
+
+}
+
diff --git a/source/8086/s_f32UIToCommonNaN.c b/source/8086/s_f32UIToCommonNaN.c
index 2bb28f8..0a14729 100644
--- a/source/8086/s_f32UIToCommonNaN.c
+++ b/source/8086/s_f32UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_f64UIToCommonNaN.c b/source/8086/s_f64UIToCommonNaN.c
index 4339ce9..bb9c2fa 100644
--- a/source/8086/s_f64UIToCommonNaN.c
+++ b/source/8086/s_f64UIToCommonNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_propagateNaNExtF80M.c b/source/8086/s_propagateNaNExtF80M.c
index 67d81ba..80b5897 100644
--- a/source/8086/s_propagateNaNExtF80M.c
+++ b/source/8086/s_propagateNaNExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_propagateNaNExtF80UI.c b/source/8086/s_propagateNaNExtF80UI.c
index 16f4251..3fc1d7a 100644
--- a/source/8086/s_propagateNaNExtF80UI.c
+++ b/source/8086/s_propagateNaNExtF80UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_propagateNaNF128M.c b/source/8086/s_propagateNaNF128M.c
index bc8b0b2..a2e869b 100644
--- a/source/8086/s_propagateNaNF128M.c
+++ b/source/8086/s_propagateNaNF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_propagateNaNF128UI.c b/source/8086/s_propagateNaNF128UI.c
index 332b4c3..c2117af 100644
--- a/source/8086/s_propagateNaNF128UI.c
+++ b/source/8086/s_propagateNaNF128UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_propagateNaNF16UI.c b/source/8086/s_propagateNaNF16UI.c
new file mode 100644
index 0000000..e18085d
--- /dev/null
+++ b/source/8086/s_propagateNaNF16UI.c
@@ -0,0 +1,84 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ bool isSigNaNA, isSigNaNB;
+ uint_fast16_t uiNonsigA, uiNonsigB, uiMagA, uiMagB;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ isSigNaNA = softfloat_isSigNaNF16UI( uiA );
+ isSigNaNB = softfloat_isSigNaNF16UI( uiB );
+ /*------------------------------------------------------------------------
+ | Make NaNs non-signaling.
+ *------------------------------------------------------------------------*/
+ uiNonsigA = uiA | 0x0200;
+ uiNonsigB = uiB | 0x0200;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( isSigNaNA | isSigNaNB ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) {
+ if ( isSigNaNB ) goto returnLargerMag;
+ return isNaNF16UI( uiB ) ? uiNonsigB : uiNonsigA;
+ } else {
+ return isNaNF16UI( uiA ) ? uiNonsigA : uiNonsigB;
+ }
+ }
+ returnLargerMag:
+ uiMagA = uiNonsigA & 0x7FFF;
+ uiMagB = uiNonsigB & 0x7FFF;
+ if ( uiMagA < uiMagB ) return uiNonsigB;
+ if ( uiMagB < uiMagA ) return uiNonsigA;
+ return (uiNonsigA < uiNonsigB) ? uiNonsigA : uiNonsigB;
+
+}
+
diff --git a/source/8086/s_propagateNaNF32UI.c b/source/8086/s_propagateNaNF32UI.c
index d941ad1..e99c449 100644
--- a/source/8086/s_propagateNaNF32UI.c
+++ b/source/8086/s_propagateNaNF32UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/s_propagateNaNF64UI.c b/source/8086/s_propagateNaNF64UI.c
index 8afbcb0..2e6c2ac 100644
--- a/source/8086/s_propagateNaNF64UI.c
+++ b/source/8086/s_propagateNaNF64UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/softfloat_raiseFlags.c b/source/8086/softfloat_raiseFlags.c
index 7b5ba25..5ba1502 100644
--- a/source/8086/softfloat_raiseFlags.c
+++ b/source/8086/softfloat_raiseFlags.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/8086/specialize.h b/source/8086/specialize.h
index 8a71e46..d2c6b22 100644
--- a/source/8086/specialize.h
+++ b/source/8086/specialize.h
@@ -2,7 +2,7 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -47,7 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define init_detectTininess softfloat_tininess_afterRounding
/*----------------------------------------------------------------------------
-| The values to return on conversions to 32-bit integer format that raise an
+| The values to return on conversions to 32-bit integer formats that raise an
| invalid exception.
*----------------------------------------------------------------------------*/
#define ui32_fromPosOverflow 0xFFFFFFFF
@@ -58,7 +58,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define i32_fromNaN 0x7FFFFFFF
/*----------------------------------------------------------------------------
-| The values to return on conversions to 64-bit integer format that raise an
+| The values to return on conversions to 64-bit integer formats that raise an
| invalid exception.
*----------------------------------------------------------------------------*/
#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
@@ -82,6 +82,41 @@ struct commonNaN {
};
/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 16-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF16UI 0xFE00
+
+/*----------------------------------------------------------------------------
+| Returns true when 16-bit unsigned integer `uiA' has the bit pattern of a
+| 16-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
+
+/*----------------------------------------------------------------------------
| The bit pattern for a default generated 32-bit floating-point NaN.
*----------------------------------------------------------------------------*/
#define defaultNaNF32UI 0xFFC00000
diff --git a/source/RISCV/extF80M_isSignalingNaN.c b/source/RISCV/extF80M_isSignalingNaN.c
index 4a05f54..be3dc40 100644
--- a/source/RISCV/extF80M_isSignalingNaN.c
+++ b/source/RISCV/extF80M_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/RISCV/f128M_isSignalingNaN.c b/source/RISCV/f128M_isSignalingNaN.c
index 9ca5fea..6560615 100644
--- a/source/RISCV/f128M_isSignalingNaN.c
+++ b/source/RISCV/f128M_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/RISCV/s_commonNaNToExtF80M.c b/source/RISCV/s_commonNaNToExtF80M.c
index 87efbc4..1327180 100644
--- a/source/RISCV/s_commonNaNToExtF80M.c
+++ b/source/RISCV/s_commonNaNToExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_commonNaNToExtF80UI.c b/source/RISCV/s_commonNaNToExtF80UI.c
index 6c0a765..a26f078 100644
--- a/source/RISCV/s_commonNaNToExtF80UI.c
+++ b/source/RISCV/s_commonNaNToExtF80UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_commonNaNToF128M.c b/source/RISCV/s_commonNaNToF128M.c
index 20cf56c..65a44ac 100644
--- a/source/RISCV/s_commonNaNToF128M.c
+++ b/source/RISCV/s_commonNaNToF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_commonNaNToF128UI.c b/source/RISCV/s_commonNaNToF128UI.c
index d46f2dc..0b1f65c 100644
--- a/source/RISCV/s_commonNaNToF128UI.c
+++ b/source/RISCV/s_commonNaNToF128UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_commonNaNToF16UI.c b/source/RISCV/s_commonNaNToF16UI.c
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/source/RISCV/s_commonNaNToF16UI.c
@@ -0,0 +1 @@
+
diff --git a/source/RISCV/s_f16UIToCommonNaN.c b/source/RISCV/s_f16UIToCommonNaN.c
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/source/RISCV/s_f16UIToCommonNaN.c
@@ -0,0 +1 @@
+
diff --git a/source/RISCV/s_propagateNaNExtF80M.c b/source/RISCV/s_propagateNaNExtF80M.c
index e397d06..75fff79 100644
--- a/source/RISCV/s_propagateNaNExtF80M.c
+++ b/source/RISCV/s_propagateNaNExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_propagateNaNExtF80UI.c b/source/RISCV/s_propagateNaNExtF80UI.c
index 57cade1..03a74eb 100644
--- a/source/RISCV/s_propagateNaNExtF80UI.c
+++ b/source/RISCV/s_propagateNaNExtF80UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_propagateNaNF128M.c b/source/RISCV/s_propagateNaNF128M.c
index 405e779..88460b7 100644
--- a/source/RISCV/s_propagateNaNF128M.c
+++ b/source/RISCV/s_propagateNaNF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_propagateNaNF128UI.c b/source/RISCV/s_propagateNaNF128UI.c
index 44b50b2..7b65f35 100644
--- a/source/RISCV/s_propagateNaNF128UI.c
+++ b/source/RISCV/s_propagateNaNF128UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_propagateNaNF16UI.c b/source/RISCV/s_propagateNaNF16UI.c
new file mode 100644
index 0000000..761f8d1
--- /dev/null
+++ b/source/RISCV/s_propagateNaNF16UI.c
@@ -0,0 +1,58 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+
+ if ( softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ return defaultNaNF16UI;
+
+}
+
diff --git a/source/RISCV/s_propagateNaNF32UI.c b/source/RISCV/s_propagateNaNF32UI.c
index ec709f9..32870e1 100644
--- a/source/RISCV/s_propagateNaNF32UI.c
+++ b/source/RISCV/s_propagateNaNF32UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/s_propagateNaNF64UI.c b/source/RISCV/s_propagateNaNF64UI.c
index 5868225..1f64042 100644
--- a/source/RISCV/s_propagateNaNF64UI.c
+++ b/source/RISCV/s_propagateNaNF64UI.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/RISCV/softfloat_raiseFlags.c b/source/RISCV/softfloat_raiseFlags.c
index 7b5ba25..5ba1502 100644
--- a/source/RISCV/softfloat_raiseFlags.c
+++ b/source/RISCV/softfloat_raiseFlags.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/RISCV/specialize.h b/source/RISCV/specialize.h
index 6975f39..35f7c5e 100644
--- a/source/RISCV/specialize.h
+++ b/source/RISCV/specialize.h
@@ -2,7 +2,7 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -48,7 +48,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define init_detectTininess softfloat_tininess_afterRounding
/*----------------------------------------------------------------------------
-| The values to return on conversions to 32-bit integer format that raise an
+| The values to return on conversions to 32-bit integer formats that raise an
| invalid exception.
*----------------------------------------------------------------------------*/
#define ui32_fromPosOverflow 0xFFFFFFFF
@@ -59,7 +59,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define i32_fromNaN 0x7FFFFFFF
/*----------------------------------------------------------------------------
-| The values to return on conversions to 64-bit integer format that raise an
+| The values to return on conversions to 64-bit integer formats that raise an
| invalid exception.
*----------------------------------------------------------------------------*/
#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
@@ -76,6 +76,41 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct commonNaN { char _unused; };
/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 16-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF16UI 0x7E00
+
+/*----------------------------------------------------------------------------
+| Returns true when 16-bit unsigned integer `uiA' has the bit pattern of a
+| 16-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+#define softfloat_f16UIToCommonNaN( uiA, zPtr ) if ( ! ((uiA) & 0x0200) ) softfloat_raiseFlags( softfloat_flag_invalid )
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+#define softfloat_commonNaNToF16UI( aPtr ) ((uint_fast16_t) defaultNaNF16UI)
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
+
+/*----------------------------------------------------------------------------
| The bit pattern for a default generated 32-bit floating-point NaN.
*----------------------------------------------------------------------------*/
#define defaultNaNF32UI 0x7FC00000
@@ -182,7 +217,7 @@ uint_fast64_t
*----------------------------------------------------------------------------*/
#if defined INLINE && ! defined softfloat_commonNaNToExtF80UI
INLINE
- struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
+struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
{
struct uint128 uiZ;
uiZ.v64 = defaultNaNExtF80UI64;
@@ -239,7 +274,7 @@ struct uint128
*----------------------------------------------------------------------------*/
#if defined INLINE && ! defined softfloat_commonNaNToF128UI
INLINE
- struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
+struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
{
struct uint128 uiZ;
uiZ.v64 = defaultNaNF128UI64;
@@ -289,9 +324,9 @@ struct uint128
*----------------------------------------------------------------------------*/
#if defined INLINE && ! defined softfloat_commonNaNToExtF80M
INLINE
- void
- softfloat_commonNaNToExtF80M(
- const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
+void
+ softfloat_commonNaNToExtF80M(
+ const struct commonNaN *aPtr, struct extFloat80M *zSPtr )
{
zSPtr->signExp = defaultNaNExtF80UI64;
zSPtr->signif = defaultNaNExtF80UI0;
@@ -318,10 +353,10 @@ void
/*----------------------------------------------------------------------------
| The bit pattern for a default generated 128-bit floating-point NaN.
*----------------------------------------------------------------------------*/
-#define defaultNaNF128UI96 0xFFFFFFFF
-#define defaultNaNF128UI64 0xFFFFFFFF
-#define defaultNaNF128UI32 0xFFFFFFFF
-#define defaultNaNF128UI0 0xFFFFFFFF
+#define defaultNaNF128UI96 0x7FFF8000
+#define defaultNaNF128UI64 0
+#define defaultNaNF128UI32 0
+#define defaultNaNF128UI0 0
/*----------------------------------------------------------------------------
| Assuming the 128-bit floating-point value pointed to by `aWPtr' is a NaN,
@@ -341,8 +376,8 @@ void
*----------------------------------------------------------------------------*/
#if defined INLINE && ! defined softfloat_commonNaNToF128M
INLINE
- void
- softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
+void
+ softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr )
{
zWPtr[indexWord( 4, 3 )] = defaultNaNF128UI96;
zWPtr[indexWord( 4, 2 )] = defaultNaNF128UI64;
diff --git a/source/extF80M_add.c b/source/extF80M_add.c
index fb64d11..83c9e44 100644
--- a/source/extF80M_add.c
+++ b/source/extF80M_add.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_div.c b/source/extF80M_div.c
index 6379cf3..4781389 100644
--- a/source/extF80M_div.c
+++ b/source/extF80M_div.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -67,7 +67,7 @@ void
bool signZ;
uint64_t sigA, x64;
int32_t expZ;
- int shiftCount;
+ int shiftDist;
uint32_t y[3], recip32, sigB[3];
int ix;
uint32_t q, qs[2];
@@ -117,12 +117,12 @@ void
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
expZ = expA - expB + 0x3FFF;
- shiftCount = 29;
+ shiftDist = 29;
if ( sigA < x64 ) {
--expZ;
- shiftCount = 30;
+ shiftDist = 30;
}
- softfloat_shortShiftLeft64To96M( sigA, shiftCount, y );
+ softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
recip32 = softfloat_approxRecip32_1( x64>>32 );
sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
x64 >>= 2;
diff --git a/source/extF80M_eq.c b/source/extF80M_eq.c
index 63d6a4c..8d6cd0d 100644
--- a/source/extF80M_eq.c
+++ b/source/extF80M_eq.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_eq_signaling.c b/source/extF80M_eq_signaling.c
index ac5ab46..3cb6019 100644
--- a/source/extF80M_eq_signaling.c
+++ b/source/extF80M_eq_signaling.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_le.c b/source/extF80M_le.c
index 7aeee13..b68b402 100644
--- a/source/extF80M_le.c
+++ b/source/extF80M_le.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_le_quiet.c b/source/extF80M_le_quiet.c
index 0522e7e..1871e76 100644
--- a/source/extF80M_le_quiet.c
+++ b/source/extF80M_le_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_lt.c b/source/extF80M_lt.c
index 81ad03a..2a0d485 100644
--- a/source/extF80M_lt.c
+++ b/source/extF80M_lt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_lt_quiet.c b/source/extF80M_lt_quiet.c
index 7719333..6cca1a2 100644
--- a/source/extF80M_lt_quiet.c
+++ b/source/extF80M_lt_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_mul.c b/source/extF80M_mul.c
index 19129cb..0c2a126 100644
--- a/source/extF80M_mul.c
+++ b/source/extF80M_mul.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_rem.c b/source/extF80M_rem.c
index 9853f79..9e2a28f 100644
--- a/source/extF80M_rem.c
+++ b/source/extF80M_rem.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_roundToInt.c b/source/extF80M_roundToInt.c
index 67c49c6..809be28 100644
--- a/source/extF80M_roundToInt.c
+++ b/source/extF80M_roundToInt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_sqrt.c b/source/extF80M_sqrt.c
index 7d572bc..24d162d 100644
--- a/source/extF80M_sqrt.c
+++ b/source/extF80M_sqrt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80M_sub.c b/source/extF80M_sub.c
index 4490e69..d3f20e9 100644
--- a/source/extF80M_sub.c
+++ b/source/extF80M_sub.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_to_f128M.c b/source/extF80M_to_f128M.c
index ee9b9f2..7644a94 100644
--- a/source/extF80M_to_f128M.c
+++ b/source/extF80M_to_f128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80M_to_f16.c b/source/extF80M_to_f16.c
new file mode 100644
index 0000000..9d465eb
--- /dev/null
+++ b/source/extF80M_to_f16.c
@@ -0,0 +1,112 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+float16_t extF80M_to_f16( const extFloat80_t *aPtr )
+{
+
+ return extF80_to_f16( *aPtr );
+
+}
+
+#else
+
+float16_t extF80M_to_f16( const extFloat80_t *aPtr )
+{
+ const struct extFloat80M *aSPtr;
+ uint_fast16_t uiA64;
+ bool sign;
+ int32_t exp;
+ uint64_t sig;
+ struct commonNaN commonNaN;
+ uint16_t uiZ, sig16;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ aSPtr = (const struct extFloat80M *) aPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA64 = aSPtr->signExp;
+ sign = signExtF80UI64( uiA64 );
+ exp = expExtF80UI64( uiA64 );
+ sig = aSPtr->signif;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x7FFF ) {
+ if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ softfloat_extF80MToCommonNaN( aSPtr, &commonNaN );
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
+ } else {
+ uiZ = packToF16UI( sign, 0x1F, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! (sig & UINT64_C( 0x8000000000000000 )) ) {
+ if ( ! sig ) {
+ uiZ = packToF16UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ exp += softfloat_normExtF80SigM( &sig );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig16 = softfloat_shortShiftRightJam64( sig, 49 );
+ exp -= 0x3FF1;
+ if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
+ if ( exp < -0x40 ) exp = -0x40;
+ }
+ return softfloat_roundPackToF16( sign, exp, sig16 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+#endif
+
diff --git a/source/extF80M_to_f32.c b/source/extF80M_to_f32.c
index 7292a06..3030ff7 100644
--- a/source/extF80M_to_f32.c
+++ b/source/extF80M_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -66,6 +66,8 @@ float32_t extF80M_to_f32( const extFloat80_t *aPtr )
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
aSPtr = (const struct extFloat80M *) aPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiA64 = aSPtr->signExp;
sign = signExtF80UI64( uiA64 );
exp = expExtF80UI64( uiA64 );
@@ -97,7 +99,7 @@ float32_t extF80M_to_f32( const extFloat80_t *aPtr )
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
- return softfloat_roundPackToF32( sign, exp, sig32 | 0x40000000 );
+ return softfloat_roundPackToF32( sign, exp, sig32 );
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
uiZ:
diff --git a/source/extF80M_to_f64.c b/source/extF80M_to_f64.c
index 725ebf5..5fea6fa 100644
--- a/source/extF80M_to_f64.c
+++ b/source/extF80M_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -66,6 +66,8 @@ float64_t extF80M_to_f64( const extFloat80_t *aPtr )
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
aSPtr = (const struct extFloat80M *) aPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiA64 = aSPtr->signExp;
sign = signExtF80UI64( uiA64 );
exp = expExtF80UI64( uiA64 );
@@ -97,9 +99,7 @@ float64_t extF80M_to_f64( const extFloat80_t *aPtr )
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
- return
- softfloat_roundPackToF64(
- sign, exp, sig | UINT64_C( 0x4000000000000000 ) );
+ return softfloat_roundPackToF64( sign, exp, sig );
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
uiZ:
diff --git a/source/extF80M_to_i32.c b/source/extF80M_to_i32.c
index 97ccb3e..dda0fe3 100644
--- a/source/extF80M_to_i32.c
+++ b/source/extF80M_to_i32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -74,7 +74,7 @@ int_fast32_t
sig = aSPtr->signif;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- shiftDist = 0x4037 - exp;
+ shiftDist = 0x4032 - exp;
if ( shiftDist <= 0 ) {
if ( sig>>32 ) goto invalid;
if ( -32 < shiftDist ) {
diff --git a/source/extF80M_to_i32_r_minMag.c b/source/extF80M_to_i32_r_minMag.c
index 33ae48f..ed1c61a 100644
--- a/source/extF80M_to_i32_r_minMag.c
+++ b/source/extF80M_to_i32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80M_to_i64.c b/source/extF80M_to_i64.c
index 4149b6e..02c6bf7 100644
--- a/source/extF80M_to_i64.c
+++ b/source/extF80M_to_i64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80M_to_i64_r_minMag.c b/source/extF80M_to_i64_r_minMag.c
index 6abbd78..8205724 100644
--- a/source/extF80M_to_i64_r_minMag.c
+++ b/source/extF80M_to_i64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80M_to_ui32.c b/source/extF80M_to_ui32.c
index 294a205..38365cd 100644
--- a/source/extF80M_to_ui32.c
+++ b/source/extF80M_to_ui32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -74,7 +74,7 @@ uint_fast32_t
sig = aSPtr->signif;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- shiftDist = 0x4037 - exp;
+ shiftDist = 0x4032 - exp;
if ( shiftDist <= 0 ) {
if ( sig>>32 ) goto invalid;
if ( -32 < shiftDist ) {
diff --git a/source/extF80M_to_ui32_r_minMag.c b/source/extF80M_to_ui32_r_minMag.c
index 300f05d..920fb7d 100644
--- a/source/extF80M_to_ui32_r_minMag.c
+++ b/source/extF80M_to_ui32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80M_to_ui64.c b/source/extF80M_to_ui64.c
index 86ea0f5..19462ec 100644
--- a/source/extF80M_to_ui64.c
+++ b/source/extF80M_to_ui64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80M_to_ui64_r_minMag.c b/source/extF80M_to_ui64_r_minMag.c
index 2b1b04e..737b563 100644
--- a/source/extF80M_to_ui64_r_minMag.c
+++ b/source/extF80M_to_ui64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80_add.c b/source/extF80_add.c
index 4081730..230b216 100644
--- a/source/extF80_add.c
+++ b/source/extF80_add.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_div.c b/source/extF80_div.c
index b4ffc59..7e0fd79 100644
--- a/source/extF80_div.c
+++ b/source/extF80_div.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_eq.c b/source/extF80_eq.c
index 95cb4ac..c23b699 100644
--- a/source/extF80_eq.c
+++ b/source/extF80_eq.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_eq_signaling.c b/source/extF80_eq_signaling.c
index 3c2871c..75ac44f 100644
--- a/source/extF80_eq_signaling.c
+++ b/source/extF80_eq_signaling.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_isSignalingNaN.c b/source/extF80_isSignalingNaN.c
index 9b1b01d..86b3a06 100644
--- a/source/extF80_isSignalingNaN.c
+++ b/source/extF80_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_le.c b/source/extF80_le.c
index e173806..aa0cbd2 100644
--- a/source/extF80_le.c
+++ b/source/extF80_le.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_le_quiet.c b/source/extF80_le_quiet.c
index c594d41..9a41c3c 100644
--- a/source/extF80_le_quiet.c
+++ b/source/extF80_le_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_lt.c b/source/extF80_lt.c
index db91445..082fb69 100644
--- a/source/extF80_lt.c
+++ b/source/extF80_lt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_lt_quiet.c b/source/extF80_lt_quiet.c
index ab2c3c3..4e68b32 100644
--- a/source/extF80_lt_quiet.c
+++ b/source/extF80_lt_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_mul.c b/source/extF80_mul.c
index 478e867..8391694 100644
--- a/source/extF80_mul.c
+++ b/source/extF80_mul.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_rem.c b/source/extF80_rem.c
index 11d3c85..e210d74 100644
--- a/source/extF80_rem.c
+++ b/source/extF80_rem.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -52,7 +52,6 @@ extFloat80_t extF80_rem( extFloat80_t a, extFloat80_t b )
union { struct extFloat80M s; extFloat80_t f; } uB;
uint_fast16_t uiB64;
uint_fast64_t uiB0;
- bool signB;
int_fast32_t expB;
uint_fast64_t sigB;
struct exp32_sig64 normExpSig;
@@ -78,7 +77,6 @@ extFloat80_t extF80_rem( extFloat80_t a, extFloat80_t b )
uB.f = b;
uiB64 = uB.s.signExp;
uiB0 = uB.s.signif;
- signB = signExtF80UI64( uiB64 );
expB = expExtF80UI64( uiB64 );
sigB = uiB0;
/*------------------------------------------------------------------------
diff --git a/source/extF80_roundToInt.c b/source/extF80_roundToInt.c
index b1fa901..8bc1561 100644
--- a/source/extF80_roundToInt.c
+++ b/source/extF80_roundToInt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_sqrt.c b/source/extF80_sqrt.c
index 9f16d66..901c86f 100644
--- a/source/extF80_sqrt.c
+++ b/source/extF80_sqrt.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -115,7 +115,7 @@ extFloat80_t extF80_sqrt( extFloat80_t a )
rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- q = ((uint_fast64_t) (uint32_t) (rem.v64>>2) * recipSqrt32)>>32;
+ q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
sigZ = ((uint_fast64_t) sig32Z<<32) + (q<<3);
x64 = ((uint_fast64_t) sig32Z<<32) + sigZ;
term = softfloat_mul64ByShifted32To128( x64, q );
@@ -123,7 +123,7 @@ extFloat80_t extF80_sqrt( extFloat80_t a )
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- q = (((uint_fast64_t) (uint32_t) (rem.v64>>2) * recipSqrt32)>>32) + 2;
+ q = (((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32) + 2;
x64 = sigZ;
sigZ = (sigZ<<1) + (q>>25);
sigZExtra = (uint64_t) (q<<39);
@@ -133,7 +133,7 @@ extFloat80_t extF80_sqrt( extFloat80_t a )
q &= ~(uint_fast64_t) 0xFFFF;
sigZExtra = (uint64_t) (q<<39);
term = softfloat_mul64ByShifted32To128( x64 + (q>>27), q );
- x64 = (uint_fast64_t) (uint32_t) (q<<5) * (uint32_t) q;
+ x64 = (uint32_t) (q<<5) * (uint_fast64_t) (uint32_t) q;
term = softfloat_add128( term.v64, term.v0, 0, x64 );
rem = softfloat_shortShiftLeft128( rem.v64, rem.v0, 28 );
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
diff --git a/source/extF80_sub.c b/source/extF80_sub.c
index f5af404..318902c 100644
--- a/source/extF80_sub.c
+++ b/source/extF80_sub.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/extF80_to_f128.c b/source/extF80_to_f128.c
index 68ddb25..5b27428 100644
--- a/source/extF80_to_f128.c
+++ b/source/extF80_to_f128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
@@ -47,26 +47,26 @@ float128_t extF80_to_f128( extFloat80_t a )
uint_fast16_t uiA64;
uint_fast64_t uiA0;
uint_fast16_t exp;
- uint_fast64_t sig;
+ uint_fast64_t frac;
struct commonNaN commonNaN;
struct uint128 uiZ;
bool sign;
- struct uint128 sig128;
+ struct uint128 frac128;
union ui128_f128 uZ;
uA.f = a;
uiA64 = uA.s.signExp;
uiA0 = uA.s.signif;
exp = expExtF80UI64( uiA64 );
- sig = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
- if ( (exp == 0x7FFF) && sig ) {
+ frac = uiA0 & UINT64_C( 0x7FFFFFFFFFFFFFFF );
+ if ( (exp == 0x7FFF) && frac ) {
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
uiZ = softfloat_commonNaNToF128UI( &commonNaN );
} else {
sign = signExtF80UI64( uiA64 );
- sig128 = softfloat_shortShiftLeft128( 0, sig, 49 );
- uiZ.v64 = packToF128UI64( sign, exp, sig128.v64 );
- uiZ.v0 = sig128.v0;
+ frac128 = softfloat_shortShiftLeft128( 0, frac, 49 );
+ uiZ.v64 = packToF128UI64( sign, exp, frac128.v64 );
+ uiZ.v0 = frac128.v0;
}
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/extF80_to_f16.c b/source/extF80_to_f16.c
new file mode 100644
index 0000000..488e9d5
--- /dev/null
+++ b/source/extF80_to_f16.c
@@ -0,0 +1,96 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t extF80_to_f16( extFloat80_t a )
+{
+ union { struct extFloat80M s; extFloat80_t f; } uA;
+ uint_fast16_t uiA64;
+ uint_fast64_t uiA0;
+ bool sign;
+ int_fast32_t exp;
+ uint_fast64_t sig;
+ struct commonNaN commonNaN;
+ uint_fast16_t uiZ, sig16;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA64 = uA.s.signExp;
+ uiA0 = uA.s.signif;
+ sign = signExtF80UI64( uiA64 );
+ exp = expExtF80UI64( uiA64 );
+ sig = uiA0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x7FFF ) {
+ if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
+ } else {
+ uiZ = packToF16UI( sign, 0x1F, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig16 = softfloat_shortShiftRightJam64( sig, 49 );
+ if ( ! (exp | sig16) ) {
+ uiZ = packToF16UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ exp -= 0x3FF1;
+ if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
+ if ( exp < -0x40 ) exp = -0x40;
+ }
+ return softfloat_roundPackToF16( sign, exp, sig16 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/extF80_to_f32.c b/source/extF80_to_f32.c
index 1acc065..19547de 100644
--- a/source/extF80_to_f32.c
+++ b/source/extF80_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -53,12 +53,16 @@ float32_t extF80_to_f32( extFloat80_t a )
uint_fast32_t uiZ, sig32;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA64 = uA.s.signExp;
uiA0 = uA.s.signif;
sign = signExtF80UI64( uiA64 );
exp = expExtF80UI64( uiA64 );
sig = uiA0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
@@ -68,16 +72,22 @@ float32_t extF80_to_f32( extFloat80_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
sig32 = softfloat_shortShiftRightJam64( sig, 33 );
if ( ! (exp | sig32) ) {
uiZ = packToF32UI( sign, 0, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
exp -= 0x3F81;
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
return softfloat_roundPackToF32( sign, exp, sig32 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/extF80_to_f64.c b/source/extF80_to_f64.c
index 5fa3e19..74710d0 100644
--- a/source/extF80_to_f64.c
+++ b/source/extF80_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -53,16 +53,22 @@ float64_t extF80_to_f64( extFloat80_t a )
uint_fast64_t uiZ;
union ui64_f64 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA64 = uA.s.signExp;
uiA0 = uA.s.signif;
sign = signExtF80UI64( uiA64 );
exp = expExtF80UI64( uiA64 );
sig = uiA0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! (exp | sig) ) {
uiZ = packToF64UI( sign, 0, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
if ( sig & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
softfloat_extF80UIToCommonNaN( uiA64, uiA0, &commonNaN );
@@ -72,12 +78,16 @@ float64_t extF80_to_f64( extFloat80_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
sig = softfloat_shortShiftRightJam64( sig, 1 );
exp -= 0x3C01;
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
return softfloat_roundPackToF64( sign, exp, sig );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/extF80_to_i32.c b/source/extF80_to_i32.c
index 2e58c0a..59347b9 100644
--- a/source/extF80_to_i32.c
+++ b/source/extF80_to_i32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -74,7 +74,7 @@ int_fast32_t
#endif
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- shiftDist = 0x4037 - exp;
+ shiftDist = 0x4032 - exp;
if ( shiftDist <= 0 ) shiftDist = 1;
sig = softfloat_shiftRightJam64( sig, shiftDist );
return softfloat_roundPackToI32( sign, sig, roundingMode, exact );
diff --git a/source/extF80_to_i32_r_minMag.c b/source/extF80_to_i32_r_minMag.c
index 0f591a4..1c0c634 100644
--- a/source/extF80_to_i32_r_minMag.c
+++ b/source/extF80_to_i32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80_to_i64.c b/source/extF80_to_i64.c
index 98815cf..48379b0 100644
--- a/source/extF80_to_i64.c
+++ b/source/extF80_to_i64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80_to_i64_r_minMag.c b/source/extF80_to_i64_r_minMag.c
index 208ce86..96f1bd6 100644
--- a/source/extF80_to_i64_r_minMag.c
+++ b/source/extF80_to_i64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80_to_ui32.c b/source/extF80_to_ui32.c
index 2717342..863623f 100644
--- a/source/extF80_to_ui32.c
+++ b/source/extF80_to_ui32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -74,7 +74,7 @@ uint_fast32_t
#endif
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- shiftDist = 0x4037 - exp;
+ shiftDist = 0x4032 - exp;
if ( shiftDist <= 0 ) shiftDist = 1;
sig = softfloat_shiftRightJam64( sig, shiftDist );
return softfloat_roundPackToUI32( sign, sig, roundingMode, exact );
diff --git a/source/extF80_to_ui32_r_minMag.c b/source/extF80_to_ui32_r_minMag.c
index 3c8c737..ffbe12b 100644
--- a/source/extF80_to_ui32_r_minMag.c
+++ b/source/extF80_to_ui32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80_to_ui64.c b/source/extF80_to_ui64.c
index 449b81b..2dbcd0f 100644
--- a/source/extF80_to_ui64.c
+++ b/source/extF80_to_ui64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/extF80_to_ui64_r_minMag.c b/source/extF80_to_ui64_r_minMag.c
index a52e407..b661b7a 100644
--- a/source/extF80_to_ui64_r_minMag.c
+++ b/source/extF80_to_ui64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128M_add.c b/source/f128M_add.c
index 2699885..a54ddb8 100644
--- a/source/f128M_add.c
+++ b/source/f128M_add.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_div.c b/source/f128M_div.c
index c9d809f..f04d035 100644
--- a/source/f128M_div.c
+++ b/source/f128M_div.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_eq.c b/source/f128M_eq.c
index 9bec2e6..9499845 100644
--- a/source/f128M_eq.c
+++ b/source/f128M_eq.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_eq_signaling.c b/source/f128M_eq_signaling.c
index 27f05ba..56b4556 100644
--- a/source/f128M_eq_signaling.c
+++ b/source/f128M_eq_signaling.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_le.c b/source/f128M_le.c
index 02c6e73..c54f7d1 100644
--- a/source/f128M_le.c
+++ b/source/f128M_le.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_le_quiet.c b/source/f128M_le_quiet.c
index fe7875d..1718d28 100644
--- a/source/f128M_le_quiet.c
+++ b/source/f128M_le_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_lt.c b/source/f128M_lt.c
index cd9cacc..9df9cce 100644
--- a/source/f128M_lt.c
+++ b/source/f128M_lt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_lt_quiet.c b/source/f128M_lt_quiet.c
index 1cf256c..d8ca5e2 100644
--- a/source/f128M_lt_quiet.c
+++ b/source/f128M_lt_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_mul.c b/source/f128M_mul.c
index 5aa1732..5563fdf 100644
--- a/source/f128M_mul.c
+++ b/source/f128M_mul.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -65,7 +65,7 @@ void
bool signZ;
const uint32_t *ptr;
uint32_t uiZ96, sigA[4];
- uint_fast8_t shiftCount;
+ uint_fast8_t shiftDist;
uint32_t sigB[4];
int32_t expZ;
uint32_t sigProd[8], *extSigZPtr;
@@ -134,12 +134,12 @@ void
sigProd[indexWord( 8, 3 )] |= 1;
}
extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
- shiftCount = 16;
+ shiftDist = 16;
if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
++expZ;
- shiftCount = 15;
+ shiftDist = 15;
}
- softfloat_shortShiftLeft160M( extSigZPtr, shiftCount, extSigZPtr );
+ softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
return;
/*------------------------------------------------------------------------
diff --git a/source/f128M_mulAdd.c b/source/f128M_mulAdd.c
index ce0b0d2..c0b7b7e 100644
--- a/source/f128M_mulAdd.c
+++ b/source/f128M_mulAdd.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_rem.c b/source/f128M_rem.c
index 7306080..a576a92 100644
--- a/source/f128M_rem.c
+++ b/source/f128M_rem.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_roundToInt.c b/source/f128M_roundToInt.c
index 049d237..8cdb8b1 100644
--- a/source/f128M_roundToInt.c
+++ b/source/f128M_roundToInt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_sqrt.c b/source/f128M_sqrt.c
index c98f832..d52b6c5 100644
--- a/source/f128M_sqrt.c
+++ b/source/f128M_sqrt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_sub.c b/source/f128M_sub.c
index e0d600b..192a987 100644
--- a/source/f128M_sub.c
+++ b/source/f128M_sub.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_to_extF80M.c b/source/f128M_to_extF80M.c
index 463009d..b842956 100644
--- a/source/f128M_to_extF80M.c
+++ b/source/f128M_to_extF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128M_to_f16.c b/source/f128M_to_f16.c
new file mode 100644
index 0000000..a974141
--- /dev/null
+++ b/source/f128M_to_f16.c
@@ -0,0 +1,113 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+float16_t f128M_to_f16( const float128_t *aPtr )
+{
+
+ return f128_to_f16( *aPtr );
+
+}
+
+#else
+
+float16_t f128M_to_f16( const float128_t *aPtr )
+{
+ const uint32_t *aWPtr;
+ uint32_t uiA96;
+ bool sign;
+ int32_t exp;
+ uint32_t frac32;
+ struct commonNaN commonNaN;
+ uint16_t uiZ, frac16;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ aWPtr = (const uint32_t *) aPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiA96 = aWPtr[indexWordHi( 4 )];
+ sign = signF128UI96( uiA96 );
+ exp = expF128UI96( uiA96 );
+ frac32 =
+ fracF128UI96( uiA96 )
+ | ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
+ | aWPtr[indexWord( 4, 0 )])
+ != 0);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x7FFF ) {
+ if ( frac32 ) {
+ softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
+ } else {
+ uiZ = packToF16UI( sign, 0x1F, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac16 = frac32>>2 | (frac32 & 3);
+ if ( ! (exp | frac16) ) {
+ uiZ = packToF16UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ exp -= 0x3FF1;
+ if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
+ if ( exp < -0x40 ) exp = -0x40;
+ }
+ return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+#endif
+
diff --git a/source/f128M_to_f32.c b/source/f128M_to_f32.c
index 104e53e..292ba2b 100644
--- a/source/f128M_to_f32.c
+++ b/source/f128M_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -58,20 +58,24 @@ float32_t f128M_to_f32( const float128_t *aPtr )
uint32_t uiA96;
bool sign;
int32_t exp;
- uint64_t sig64;
+ uint64_t frac64;
struct commonNaN commonNaN;
- uint32_t uiZ, sig32;
+ uint32_t uiZ, frac32;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
aWPtr = (const uint32_t *) aPtr;
uiA96 = aWPtr[indexWordHi( 4 )];
sign = signF128UI96( uiA96 );
exp = expF128UI96( uiA96 );
- sig64 =
+ frac64 =
(uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )]
| ((aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )]) != 0);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
- if ( sig64 ) {
+ if ( frac64 ) {
softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
} else {
@@ -79,16 +83,22 @@ float32_t f128M_to_f32( const float128_t *aPtr )
}
goto uiZ;
}
- sig32 = softfloat_shortShiftRightJam64( sig64, 18 );
- if ( ! (exp | sig32) ) {
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
+ if ( ! (exp | frac32) ) {
uiZ = packToF32UI( sign, 0, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
exp -= 0x3F81;
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
- return softfloat_roundPackToF32( sign, exp, sig32 | 0x40000000 );
+ return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f128M_to_f64.c b/source/f128M_to_f64.c
index e892f14..f5c60d4 100644
--- a/source/f128M_to_f64.c
+++ b/source/f128M_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -58,19 +58,23 @@ float64_t f128M_to_f64( const float128_t *aPtr )
uint32_t uiA96;
bool sign;
int32_t exp;
- uint64_t sig64;
+ uint64_t frac64;
struct commonNaN commonNaN;
uint64_t uiZ;
- uint32_t sig32;
+ uint32_t frac32;
union ui64_f64 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
aWPtr = (const uint32_t *) aPtr;
uiA96 = aWPtr[indexWordHi( 4 )];
sign = signF128UI96( uiA96 );
exp = expF128UI96( uiA96 );
- sig64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
+ frac64 = (uint64_t) fracF128UI96( uiA96 )<<32 | aWPtr[indexWord( 4, 2 )];
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
- if ( sig64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
+ if ( frac64 || aWPtr[indexWord( 4, 1 )] | aWPtr[indexWord( 4, 0 )] ) {
softfloat_f128MToCommonNaN( aWPtr, &commonNaN );
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
} else {
@@ -78,20 +82,26 @@ float64_t f128M_to_f64( const float128_t *aPtr )
}
goto uiZ;
}
- sig32 = aWPtr[indexWord( 4, 1 )];
- sig64 = sig64<<14 | sig32>>18;
- if ( (sig32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) sig64 |= 1;
- if ( ! exp && ! sig64 ) {
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac32 = aWPtr[indexWord( 4, 1 )];
+ frac64 = frac64<<14 | frac32>>18;
+ if ( (frac32 & 0x0003FFFF) || aWPtr[indexWord( 4, 0 )] ) frac64 |= 1;
+ if ( ! (exp | frac64) ) {
uiZ = packToF64UI( sign, 0, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
exp -= 0x3C01;
if ( sizeof (int_fast16_t) < sizeof (int32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
return
softfloat_roundPackToF64(
- sign, exp, sig64 | UINT64_C( 0x4000000000000000 ) );
+ sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f128M_to_i32.c b/source/f128M_to_i32.c
index dcf83a4..2ff0a53 100644
--- a/source/f128M_to_i32.c
+++ b/source/f128M_to_i32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -88,7 +88,7 @@ int_fast32_t
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
- shiftDist = 0x4028 - exp;
+ shiftDist = 0x4023 - exp;
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
return softfloat_roundPackToI32( sign, sig64, roundingMode, exact );
diff --git a/source/f128M_to_i32_r_minMag.c b/source/f128M_to_i32_r_minMag.c
index 44c94ec..6c95a8e 100644
--- a/source/f128M_to_i32_r_minMag.c
+++ b/source/f128M_to_i32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128M_to_i64.c b/source/f128M_to_i64.c
index 766bf33..481deed 100644
--- a/source/f128M_to_i64.c
+++ b/source/f128M_to_i64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128M_to_i64_r_minMag.c b/source/f128M_to_i64_r_minMag.c
index 07e6fa7..479b54f 100644
--- a/source/f128M_to_i64_r_minMag.c
+++ b/source/f128M_to_i64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128M_to_ui32.c b/source/f128M_to_ui32.c
index 86161be..802e147 100644
--- a/source/f128M_to_ui32.c
+++ b/source/f128M_to_ui32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -88,7 +88,7 @@ uint_fast32_t
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
- shiftDist = 0x4028 - exp;
+ shiftDist = 0x4023 - exp;
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
return softfloat_roundPackToUI32( sign, sig64, roundingMode, exact );
diff --git a/source/f128M_to_ui32_r_minMag.c b/source/f128M_to_ui32_r_minMag.c
index 03c4d3f..b669337 100644
--- a/source/f128M_to_ui32_r_minMag.c
+++ b/source/f128M_to_ui32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128M_to_ui64.c b/source/f128M_to_ui64.c
index 73f8e78..e771f60 100644
--- a/source/f128M_to_ui64.c
+++ b/source/f128M_to_ui64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128M_to_ui64_r_minMag.c b/source/f128M_to_ui64_r_minMag.c
index 6a5357b..891f8b9 100644
--- a/source/f128M_to_ui64_r_minMag.c
+++ b/source/f128M_to_ui64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128_add.c b/source/f128_add.c
index eb896a5..f1e8fd9 100644
--- a/source/f128_add.c
+++ b/source/f128_add.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_div.c b/source/f128_div.c
index d140097..a6cf7c4 100644
--- a/source/f128_div.c
+++ b/source/f128_div.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_eq.c b/source/f128_eq.c
index 81452d6..5c326b7 100644
--- a/source/f128_eq.c
+++ b/source/f128_eq.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_eq_signaling.c b/source/f128_eq_signaling.c
index a7529eb..332011d 100644
--- a/source/f128_eq_signaling.c
+++ b/source/f128_eq_signaling.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_isSignalingNaN.c b/source/f128_isSignalingNaN.c
index 59fb394..74932ee 100644
--- a/source/f128_isSignalingNaN.c
+++ b/source/f128_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_le.c b/source/f128_le.c
index 9dc86f7..3bda15c 100644
--- a/source/f128_le.c
+++ b/source/f128_le.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_le_quiet.c b/source/f128_le_quiet.c
index e8060ff..8990018 100644
--- a/source/f128_le_quiet.c
+++ b/source/f128_le_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_lt.c b/source/f128_lt.c
index 2a0c5c5..e20fc7b 100644
--- a/source/f128_lt.c
+++ b/source/f128_lt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_lt_quiet.c b/source/f128_lt_quiet.c
index 3accea7..97c760e 100644
--- a/source/f128_lt_quiet.c
+++ b/source/f128_lt_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_mul.c b/source/f128_mul.c
index 826b140..0168964 100644
--- a/source/f128_mul.c
+++ b/source/f128_mul.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_mulAdd.c b/source/f128_mulAdd.c
index 4dadabc..11e6ed2 100644
--- a/source/f128_mulAdd.c
+++ b/source/f128_mulAdd.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_rem.c b/source/f128_rem.c
index ea303ae..6a50199 100644
--- a/source/f128_rem.c
+++ b/source/f128_rem.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -50,7 +50,6 @@ float128_t f128_rem( float128_t a, float128_t b )
struct uint128 sigA;
union ui128_f128 uB;
uint_fast64_t uiB64, uiB0;
- bool signB;
int_fast32_t expB;
struct uint128 sigB;
struct exp32_sig128 normExpSig;
@@ -75,7 +74,6 @@ float128_t f128_rem( float128_t a, float128_t b )
uB.f = b;
uiB64 = uB.ui.v64;
uiB0 = uB.ui.v0;
- signB = signF128UI64( uiB64 );
expB = expF128UI64( uiB64 );
sigB.v64 = fracF128UI64( uiB64 );
sigB.v0 = uiB0;
diff --git a/source/f128_roundToInt.c b/source/f128_roundToInt.c
index 63e9966..45f633d 100644
--- a/source/f128_roundToInt.c
+++ b/source/f128_roundToInt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_sqrt.c b/source/f128_sqrt.c
index 2b32b3e..304bbc7 100644
--- a/source/f128_sqrt.c
+++ b/source/f128_sqrt.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -114,7 +114,7 @@ float128_t f128_sqrt( float128_t a )
rem.v64 -= (uint_fast64_t) sig32Z * sig32Z;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- q = ((uint_fast64_t) (uint32_t) (rem.v64>>2) * recipSqrt32)>>32;
+ q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
qs[1] = q;
x64 = (uint_fast64_t) sig32Z<<32;
sig64Z = x64 + ((uint_fast64_t) q<<3);
@@ -124,7 +124,7 @@ float128_t f128_sqrt( float128_t a )
rem = softfloat_sub128( rem.v64, rem.v0, term.v64, term.v0 );
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- q = ((uint_fast64_t) (uint32_t) (rem.v64>>2) * recipSqrt32)>>32;
+ q = ((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32;
y = softfloat_shortShiftLeft128( rem.v64, rem.v0, 29 );
sig64Z <<= 1;
/*------------------------------------------------------------------------
@@ -141,7 +141,7 @@ float128_t f128_sqrt( float128_t a )
qs[0] = q;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- q = (((uint_fast64_t) (uint32_t) (rem.v64>>2) * recipSqrt32)>>32) + 2;
+ q = (((uint32_t) (rem.v64>>2) * (uint_fast64_t) recipSqrt32)>>32) + 2;
sigZExtra = (uint64_t) ((uint_fast64_t) q<<59);
term = softfloat_shortShiftLeft128( 0, qs[1], 53 );
sigZ =
diff --git a/source/f128_sub.c b/source/f128_sub.c
index 8d4892f..d0a3368 100644
--- a/source/f128_sub.c
+++ b/source/f128_sub.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f128_to_extF80.c b/source/f128_to_extF80.c
index f1dd92a..bfbb580 100644
--- a/source/f128_to_extF80.c
+++ b/source/f128_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,7 +47,7 @@ extFloat80_t f128_to_extF80( float128_t a )
uint_fast64_t uiA64, uiA0;
bool sign;
int_fast32_t exp;
- uint_fast64_t sig64, sig0;
+ uint_fast64_t frac64, frac0;
struct commonNaN commonNaN;
struct uint128 uiZ;
uint_fast16_t uiZ64;
@@ -56,15 +56,19 @@ extFloat80_t f128_to_extF80( float128_t a )
struct uint128 sig128;
union { struct extFloat80M s; extFloat80_t f; } uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA64 = uA.ui.v64;
uiA0 = uA.ui.v0;
- sign = signF128UI64( uiA64 );
- exp = expF128UI64( uiA64 );
- sig64 = fracF128UI64( uiA64 );
- sig0 = uiA0;
+ sign = signF128UI64( uiA64 );
+ exp = expF128UI64( uiA64 );
+ frac64 = fracF128UI64( uiA64 );
+ frac0 = uiA0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
- if ( sig64 | sig0 ) {
+ if ( frac64 | frac0 ) {
softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
uiZ64 = uiZ.v64;
@@ -75,21 +79,27 @@ extFloat80_t f128_to_extF80( float128_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! (sig64 | sig0) ) {
+ if ( ! (frac64 | frac0) ) {
uiZ64 = packToExtF80UI64( sign, 0 );
uiZ0 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF128Sig( sig64, sig0 );
+ normExpSig = softfloat_normSubnormalF128Sig( frac64, frac0 );
exp = normExpSig.exp;
- sig64 = normExpSig.sig.v64;
- sig0 = normExpSig.sig.v0;
- } else {
- sig64 |= UINT64_C( 0x0001000000000000 );
+ frac64 = normExpSig.sig.v64;
+ frac0 = normExpSig.sig.v0;
}
- sig128 = softfloat_shortShiftLeft128( sig64, sig0, 15 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig128 =
+ softfloat_shortShiftLeft128(
+ frac64 | UINT64_C( 0x0001000000000000 ), frac0, 15 );
return softfloat_roundPackToExtF80( sign, exp, sig128.v64, sig128.v0, 80 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.s.signExp = uiZ64;
uZ.s.signif = uiZ0;
diff --git a/source/f128_to_f16.c b/source/f128_to_f16.c
new file mode 100644
index 0000000..cf80b9f
--- /dev/null
+++ b/source/f128_to_f16.c
@@ -0,0 +1,95 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t f128_to_f16( float128_t a )
+{
+ union ui128_f128 uA;
+ uint_fast64_t uiA64, uiA0;
+ bool sign;
+ int_fast32_t exp;
+ uint_fast64_t frac64;
+ struct commonNaN commonNaN;
+ uint_fast16_t uiZ, frac16;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA64 = uA.ui.v64;
+ uiA0 = uA.ui.v0;
+ sign = signF128UI64( uiA64 );
+ exp = expF128UI64( uiA64 );
+ frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x7FFF ) {
+ if ( frac64 ) {
+ softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
+ } else {
+ uiZ = packToF16UI( sign, 0x1F, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac16 = softfloat_shortShiftRightJam64( frac64, 34 );
+ if ( ! (exp | frac16) ) {
+ uiZ = packToF16UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ exp -= 0x3FF1;
+ if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
+ if ( exp < -0x40 ) exp = -0x40;
+ }
+ return softfloat_roundPackToF16( sign, exp, frac16 | 0x4000 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f128_to_f32.c b/source/f128_to_f32.c
index c773e82..d435b59 100644
--- a/source/f128_to_f32.c
+++ b/source/f128_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,19 +47,23 @@ float32_t f128_to_f32( float128_t a )
uint_fast64_t uiA64, uiA0;
bool sign;
int_fast32_t exp;
- uint_fast64_t sig64;
+ uint_fast64_t frac64;
struct commonNaN commonNaN;
- uint_fast32_t uiZ, sig32;
+ uint_fast32_t uiZ, frac32;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA64 = uA.ui.v64;
uiA0 = uA.ui.v0;
sign = signF128UI64( uiA64 );
exp = expF128UI64( uiA64 );
- sig64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
+ frac64 = fracF128UI64( uiA64 ) | (uiA0 != 0);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
- if ( sig64 ) {
+ if ( frac64 ) {
softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
} else {
@@ -67,16 +71,22 @@ float32_t f128_to_f32( float128_t a )
}
goto uiZ;
}
- sig32 = softfloat_shortShiftRightJam64( sig64, 18 );
- if ( ! (exp | sig32) ) {
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac32 = softfloat_shortShiftRightJam64( frac64, 18 );
+ if ( ! (exp | frac32) ) {
uiZ = packToF32UI( sign, 0, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
exp -= 0x3F81;
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
- return softfloat_roundPackToF32( sign, exp, sig32 | 0x40000000 );
+ return softfloat_roundPackToF32( sign, exp, frac32 | 0x40000000 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f128_to_f64.c b/source/f128_to_f64.c
index 2fbc237..a324690 100644
--- a/source/f128_to_f64.c
+++ b/source/f128_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,21 +47,25 @@ float64_t f128_to_f64( float128_t a )
uint_fast64_t uiA64, uiA0;
bool sign;
int_fast32_t exp;
- uint_fast64_t sig64, sig0;
+ uint_fast64_t frac64, frac0;
struct commonNaN commonNaN;
uint_fast64_t uiZ;
- struct uint128 sig128;
+ struct uint128 frac128;
union ui64_f64 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA64 = uA.ui.v64;
uiA0 = uA.ui.v0;
sign = signF128UI64( uiA64 );
exp = expF128UI64( uiA64 );
- sig64 = fracF128UI64( uiA64 );
- sig0 = uiA0;
+ frac64 = fracF128UI64( uiA64 );
+ frac0 = uiA0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FFF ) {
- if ( sig64 | sig0 ) {
+ if ( frac64 | frac0 ) {
softfloat_f128UIToCommonNaN( uiA64, uiA0, &commonNaN );
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
} else {
@@ -69,19 +73,25 @@ float64_t f128_to_f64( float128_t a )
}
goto uiZ;
}
- sig128 = softfloat_shortShiftLeft128( sig64, sig0, 14 );
- sig64 = sig128.v64 | (sig128.v0 != 0);
- if ( ! (exp | sig64) ) {
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac128 = softfloat_shortShiftLeft128( frac64, frac0, 14 );
+ frac64 = frac128.v64 | (frac128.v0 != 0);
+ if ( ! (exp | frac64) ) {
uiZ = packToF64UI( sign, 0, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
exp -= 0x3C01;
if ( sizeof (int_fast16_t) < sizeof (int_fast32_t) ) {
if ( exp < -0x1000 ) exp = -0x1000;
}
return
softfloat_roundPackToF64(
- sign, exp, sig64 | UINT64_C( 0x4000000000000000 ) );
+ sign, exp, frac64 | UINT64_C( 0x4000000000000000 ) );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f128_to_i32.c b/source/f128_to_i32.c
index c5fa25d..c75a3b3 100644
--- a/source/f128_to_i32.c
+++ b/source/f128_to_i32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -77,7 +77,7 @@ int_fast32_t f128_to_i32( float128_t a, uint_fast8_t roundingMode, bool exact )
*------------------------------------------------------------------------*/
if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
sig64 |= (sig0 != 0);
- shiftDist = 0x4028 - exp;
+ shiftDist = 0x4023 - exp;
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
return softfloat_roundPackToI32( sign, sig64, roundingMode, exact );
diff --git a/source/f128_to_i32_r_minMag.c b/source/f128_to_i32_r_minMag.c
index 4106245..f5f6eca 100644
--- a/source/f128_to_i32_r_minMag.c
+++ b/source/f128_to_i32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128_to_i64.c b/source/f128_to_i64.c
index 85471f5..57a92e0 100644
--- a/source/f128_to_i64.c
+++ b/source/f128_to_i64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128_to_i64_r_minMag.c b/source/f128_to_i64_r_minMag.c
index d3061a9..f873ec5 100644
--- a/source/f128_to_i64_r_minMag.c
+++ b/source/f128_to_i64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128_to_ui32.c b/source/f128_to_ui32.c
index 7e1f4c8..37990fd 100644
--- a/source/f128_to_ui32.c
+++ b/source/f128_to_ui32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -76,7 +76,7 @@ uint_fast32_t
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( exp ) sig64 |= UINT64_C( 0x0001000000000000 );
- shiftDist = 0x4028 - exp;
+ shiftDist = 0x4023 - exp;
if ( 0 < shiftDist ) {
sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
}
diff --git a/source/f128_to_ui32_r_minMag.c b/source/f128_to_ui32_r_minMag.c
index 5e45bb6..759c836 100644
--- a/source/f128_to_ui32_r_minMag.c
+++ b/source/f128_to_ui32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128_to_ui64.c b/source/f128_to_ui64.c
index e394c22..a660e7b 100644
--- a/source/f128_to_ui64.c
+++ b/source/f128_to_ui64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f128_to_ui64_r_minMag.c b/source/f128_to_ui64_r_minMag.c
index 6bd0144..19a6812 100644
--- a/source/f128_to_ui64_r_minMag.c
+++ b/source/f128_to_ui64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f16_add.c b/source/f16_add.c
new file mode 100644
index 0000000..9e64384
--- /dev/null
+++ b/source/f16_add.c
@@ -0,0 +1,70 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t f16_add( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
+ float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
+#endif
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
+ if ( signF16UI( uiA ^ uiB ) ) {
+ return softfloat_subMagsF16( uiA, uiB );
+ } else {
+ return softfloat_addMagsF16( uiA, uiB );
+ }
+#else
+ magsFuncPtr =
+ signF16UI( uiA ^ uiB ) ? softfloat_subMagsF16 : softfloat_addMagsF16;
+ return (*magsFuncPtr)( uiA, uiB );
+#endif
+
+}
+
diff --git a/source/f16_div.c b/source/f16_div.c
new file mode 100644
index 0000000..b81457d
--- /dev/null
+++ b/source/f16_div.c
@@ -0,0 +1,186 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+extern const uint16_t softfloat_approxRecip_1k0s[];
+extern const uint16_t softfloat_approxRecip_1k1s[];
+
+float16_t f16_div( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ bool signZ;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expZ;
+#ifdef SOFTFLOAT_FAST_DIV32TO16
+ uint_fast32_t sig32A;
+ uint_fast16_t sigZ;
+#else
+ int index;
+ uint16_t r0;
+ uint_fast16_t sigZ, rem;
+#endif
+ uint_fast16_t uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ uB.f = b;
+ uiB = uB.ui;
+ signB = signF16UI( uiB );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA ) goto propagateNaN;
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ goto invalid;
+ }
+ goto infinity;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ goto zero;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) {
+ if ( ! (expA | sigA) ) goto invalid;
+ softfloat_raiseFlags( softfloat_flag_infinite );
+ goto infinity;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA - expB + 0xE;
+ sigA |= 0x0400;
+ sigB |= 0x0400;
+#ifdef SOFTFLOAT_FAST_DIV32TO16
+ if ( sigA < sigB ) {
+ --expZ;
+ sig32A = (uint_fast32_t) sigA<<15;
+ } else {
+ sig32A = (uint_fast32_t) sigA<<14;
+ }
+ sigZ = sig32A / sigB;
+ if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
+#else
+ if ( sigA < sigB ) {
+ --expZ;
+ sigA <<= 5;
+ } else {
+ sigA <<= 4;
+ }
+ index = sigB>>6 & 0xF;
+ r0 = softfloat_approxRecip_1k0s[index]
+ - (((uint_fast32_t) softfloat_approxRecip_1k1s[index]
+ * (sigB & 0x3F))
+ >>10);
+ sigZ = ((uint_fast32_t) sigA * r0)>>16;
+ rem = (sigA<<10) - sigZ * sigB;
+ sigZ += (rem * (uint_fast32_t) r0)>>26;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ ++sigZ;
+ if ( ! (sigZ & 7) ) {
+ sigZ &= ~1;
+ rem = (sigA<<10) - sigZ * sigB;
+ if ( rem & 0x8000 ) {
+ sigZ -= 2;
+ } else {
+ if ( rem ) sigZ |= 1;
+ }
+ }
+#endif
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infinity:
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF16UI( signZ, 0, 0 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_eq.c b/source/f16_eq.c
new file mode 100644
index 0000000..c5cb784
--- /dev/null
+++ b/source/f16_eq.c
@@ -0,0 +1,66 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+bool f16_eq( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
+ if (
+ softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
+ ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ return false;
+ }
+ return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
+
+}
+
diff --git a/source/f16_eq_signaling.c b/source/f16_eq_signaling.c
new file mode 100644
index 0000000..aa9d383
--- /dev/null
+++ b/source/f16_eq_signaling.c
@@ -0,0 +1,61 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+bool f16_eq_signaling( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return false;
+ }
+ return (uiA == uiB) || ! (uint16_t) ((uiA | uiB)<<1);
+
+}
+
diff --git a/source/f16_isSignalingNaN.c b/source/f16_isSignalingNaN.c
new file mode 100644
index 0000000..cc32693
--- /dev/null
+++ b/source/f16_isSignalingNaN.c
@@ -0,0 +1,51 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+bool f16_isSignalingNaN( float16_t a )
+{
+ union ui16_f16 uA;
+
+ uA.f = a;
+ return softfloat_isSigNaNF16UI( uA.ui );
+
+}
+
diff --git a/source/f16_le.c b/source/f16_le.c
new file mode 100644
index 0000000..277d6ed
--- /dev/null
+++ b/source/f16_le.c
@@ -0,0 +1,66 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+bool f16_le( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signA, signB;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return false;
+ }
+ signA = signF16UI( uiA );
+ signB = signF16UI( uiB );
+ return
+ (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
+ : (uiA == uiB) || (signA ^ (uiA < uiB));
+
+}
+
diff --git a/source/f16_le_quiet.c b/source/f16_le_quiet.c
new file mode 100644
index 0000000..a4e6369
--- /dev/null
+++ b/source/f16_le_quiet.c
@@ -0,0 +1,71 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+bool f16_le_quiet( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signA, signB;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
+ if (
+ softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
+ ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ return false;
+ }
+ signA = signF16UI( uiA );
+ signB = signF16UI( uiB );
+ return
+ (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
+ : (uiA == uiB) || (signA ^ (uiA < uiB));
+
+}
+
diff --git a/source/f16_lt.c b/source/f16_lt.c
new file mode 100644
index 0000000..64b9701
--- /dev/null
+++ b/source/f16_lt.c
@@ -0,0 +1,66 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+bool f16_lt( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signA, signB;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return false;
+ }
+ signA = signF16UI( uiA );
+ signB = signF16UI( uiB );
+ return
+ (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
+ : (uiA != uiB) && (signA ^ (uiA < uiB));
+
+}
+
diff --git a/source/f16_lt_quiet.c b/source/f16_lt_quiet.c
new file mode 100644
index 0000000..d006a90
--- /dev/null
+++ b/source/f16_lt_quiet.c
@@ -0,0 +1,71 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+bool f16_lt_quiet( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signA, signB;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
+ if (
+ softfloat_isSigNaNF16UI( uiA ) || softfloat_isSigNaNF16UI( uiB )
+ ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ return false;
+ }
+ signA = signF16UI( uiA );
+ signB = signF16UI( uiB );
+ return
+ (signA != signB) ? signA && ((uint16_t) ((uiA | uiB)<<1) != 0)
+ : (uiA != uiB) && (signA ^ (uiA < uiB));
+
+}
+
diff --git a/source/f16_mul.c b/source/f16_mul.c
new file mode 100644
index 0000000..8dc5787
--- /dev/null
+++ b/source/f16_mul.c
@@ -0,0 +1,140 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t f16_mul( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ bool signZ;
+ uint_fast16_t magBits;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expZ;
+ uint_fast32_t sig32Z;
+ uint_fast16_t sigZ, uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ uB.f = b;
+ uiB = uB.ui;
+ signB = signF16UI( uiB );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
+ magBits = expB | sigB;
+ goto infArg;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ magBits = expA | sigA;
+ goto infArg;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zero;
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0xF;
+ sigA = (sigA | 0x0400)<<4;
+ sigB = (sigB | 0x0400)<<5;
+ sig32Z = (uint_fast32_t) sigA * sigB;
+ sigZ = sig32Z>>16;
+ if ( sig32Z & 0xFFFF ) sigZ |= 1;
+ if ( sigZ < 0x4000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infArg:
+ if ( ! magBits ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ } else {
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ }
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF16UI( signZ, 0, 0 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_mulAdd.c b/source/f16_mulAdd.c
new file mode 100644
index 0000000..26a78c3
--- /dev/null
+++ b/source/f16_mulAdd.c
@@ -0,0 +1,60 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t f16_mulAdd( float16_t a, float16_t b, float16_t c )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ union ui16_f16 uC;
+ uint_fast16_t uiC;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ uC.f = c;
+ uiC = uC.ui;
+ return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
+
+}
+
diff --git a/source/f16_rem.c b/source/f16_rem.c
new file mode 100644
index 0000000..1f8f2ee
--- /dev/null
+++ b/source/f16_rem.c
@@ -0,0 +1,171 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t f16_rem( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ struct exp8_sig16 normExpSig;
+ uint16_t rem;
+ int_fast8_t expDiff;
+ uint_fast16_t q;
+ uint32_t recip32, q32;
+ uint16_t altRem, meanRem;
+ bool signRem;
+ uint_fast16_t uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ uB.f = b;
+ uiB = uB.ui;
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
+ goto invalid;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) goto invalid;
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ rem = sigA | 0x0400;
+ sigB |= 0x0400;
+ expDiff = expA - expB;
+ if ( expDiff < 1 ) {
+ if ( expDiff < -1 ) return a;
+ sigB <<= 3;
+ if ( expDiff ) {
+ rem <<= 2;
+ q = 0;
+ } else {
+ rem <<= 3;
+ q = (sigB <= rem);
+ if ( q ) rem -= sigB;
+ }
+ } else {
+ recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
+ /*--------------------------------------------------------------------
+ | Changing the shift of `rem' here requires also changing the initial
+ | subtraction from `expDiff'.
+ *--------------------------------------------------------------------*/
+ rem <<= 4;
+ expDiff -= 31;
+ /*--------------------------------------------------------------------
+ | The scale of `sigB' affects how many bits are obtained during each
+ | cycle of the loop. Currently this is 29 bits per loop iteration,
+ | which is believed to be the maximum possible.
+ *--------------------------------------------------------------------*/
+ sigB <<= 3;
+ for (;;) {
+ q32 = (rem * (uint_fast64_t) recip32)>>16;
+ if ( expDiff < 0 ) break;
+ rem = -((uint_fast16_t) q32 * sigB);
+ expDiff -= 29;
+ }
+ /*--------------------------------------------------------------------
+ | (`expDiff' cannot be less than -30 here.)
+ *--------------------------------------------------------------------*/
+ q32 >>= ~expDiff & 31;
+ q = q32;
+ rem = (rem<<(expDiff + 30)) - q * sigB;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ do {
+ altRem = rem;
+ ++q;
+ rem -= sigB;
+ } while ( ! (rem & 0x8000) );
+ meanRem = rem + altRem;
+ if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
+ signRem = signA;
+ if ( 0x8000 <= rem ) {
+ signRem = ! signRem;
+ rem = -rem;
+ }
+ return softfloat_normRoundPackToF16( signRem, expB, rem );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_roundToInt.c b/source/f16_roundToInt.c
new file mode 100644
index 0000000..9fa9693
--- /dev/null
+++ b/source/f16_roundToInt.c
@@ -0,0 +1,111 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t uiZ, lastBitMask, roundBitsMask;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp <= 0xE ) {
+ if ( ! (uint16_t) (uiA<<1) ) return a;
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ uiZ = uiA & packToF16UI( 1, 0, 0 );
+ switch ( roundingMode ) {
+ case softfloat_round_near_even:
+ if ( ! fracF16UI( uiA ) ) break;
+ case softfloat_round_near_maxMag:
+ if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
+ break;
+ case softfloat_round_min:
+ if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
+ break;
+ case softfloat_round_max:
+ if ( ! uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
+ break;
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x19 <= exp ) {
+ if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
+ uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
+ goto uiZ;
+ }
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = uiA;
+ lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
+ roundBitsMask = lastBitMask - 1;
+ if ( roundingMode == softfloat_round_near_maxMag ) {
+ uiZ += lastBitMask>>1;
+ } else if ( roundingMode == softfloat_round_near_even ) {
+ uiZ += lastBitMask>>1;
+ if ( ! (uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
+ } else if ( roundingMode != softfloat_round_minMag ) {
+ if ( signF16UI( uiZ ) ^ (roundingMode == softfloat_round_max) ) {
+ uiZ += roundBitsMask;
+ }
+ }
+ uiZ &= ~roundBitsMask;
+ if ( exact && (uiZ != uiA) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_sqrt.c b/source/f16_sqrt.c
new file mode 100644
index 0000000..347d77f
--- /dev/null
+++ b/source/f16_sqrt.c
@@ -0,0 +1,136 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
+extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
+
+float16_t f16_sqrt( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA, uiZ;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expZ;
+ int index;
+ uint_fast16_t r0;
+ uint_fast32_t ESqrR0;
+ uint16_t sigma0;
+ uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
+ uint16_t negRem;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA ) {
+ uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
+ goto uiZ;
+ }
+ if ( ! signA ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signA ) {
+ if ( ! (expA | sigA) ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = ((expA - 0xF)>>1) + 0xE;
+ expA &= 1;
+ sigA |= 0x0400;
+ index = (sigA>>6 & 0xE) + expA;
+ r0 = softfloat_approxRecipSqrt_1k0s[index]
+ - (((uint_fast32_t) softfloat_approxRecipSqrt_1k1s[index]
+ * (sigA & 0x7F))
+ >>11);
+ ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
+ if ( expA ) ESqrR0 >>= 1;
+ sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
+ recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
+ if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
+ sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
+ if ( expA ) sigZ >>= 1;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ ++sigZ;
+ if ( ! (sigZ & 7) ) {
+ shiftedSigZ = sigZ>>1;
+ negRem = shiftedSigZ * shiftedSigZ;
+ sigZ &= ~1;
+ if ( negRem & 0x8000 ) {
+ sigZ |= 1;
+ } else {
+ if ( negRem ) --sigZ;
+ }
+ }
+ return softfloat_roundPackToF16( 0, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_sub.c b/source/f16_sub.c
new file mode 100644
index 0000000..e5cf6e2
--- /dev/null
+++ b/source/f16_sub.c
@@ -0,0 +1,70 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t f16_sub( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
+ float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
+#endif
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
+ if ( signF16UI( uiA ^ uiB ) ) {
+ return softfloat_addMagsF16( uiA, uiB );
+ } else {
+ return softfloat_subMagsF16( uiA, uiB );
+ }
+#else
+ magsFuncPtr =
+ signF16UI( uiA ^ uiB ) ? softfloat_addMagsF16 : softfloat_subMagsF16;
+ return (*magsFuncPtr)( uiA, uiB );
+#endif
+
+}
+
diff --git a/source/f16_to_extF80.c b/source/f16_to_extF80.c
new file mode 100644
index 0000000..74cc831
--- /dev/null
+++ b/source/f16_to_extF80.c
@@ -0,0 +1,101 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+extFloat80_t f16_to_extF80( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ struct uint128 uiZ;
+ uint_fast16_t uiZ64;
+ uint_fast64_t uiZ0;
+ struct exp8_sig16 normExpSig;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
+ uiZ64 = uiZ.v64;
+ uiZ0 = uiZ.v0;
+ } else {
+ uiZ64 = packToExtF80UI64( sign, 0x7FFF );
+ uiZ0 = UINT64_C( 0x8000000000000000 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ64 = packToExtF80UI64( sign, 0 );
+ uiZ0 = 0;
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
+ uiZ0 = (uint_fast64_t) (frac | 0x0400)<<53;
+ uiZ:
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = uiZ0;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_to_extF80M.c b/source/f16_to_extF80M.c
new file mode 100644
index 0000000..a2c3e07
--- /dev/null
+++ b/source/f16_to_extF80M.c
@@ -0,0 +1,111 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
+{
+
+ *zPtr = f16_to_extF80( a );
+
+}
+
+#else
+
+void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
+{
+ struct extFloat80M *zSPtr;
+ union ui16_f16 uA;
+ uint16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint16_t frac;
+ struct commonNaN commonNaN;
+ uint_fast16_t uiZ64;
+ uint32_t uiZ32;
+ struct exp8_sig16 normExpSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zSPtr = (struct extFloat80M *) zPtr;
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
+ return;
+ }
+ uiZ64 = packToExtF80UI64( sign, 0x7FFF );
+ uiZ32 = 0x80000000;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ64 = packToExtF80UI64( sign, 0 );
+ uiZ32 = 0;
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
+ uiZ32 = 0x80000000 | (uint32_t) frac<<21;
+ uiZ:
+ zSPtr->signExp = uiZ64;
+ zSPtr->signif = (uint64_t) uiZ32<<32;
+
+}
+
+#endif
+
diff --git a/source/f16_to_f128.c b/source/f16_to_f128.c
new file mode 100644
index 0000000..ab40fb0
--- /dev/null
+++ b/source/f16_to_f128.c
@@ -0,0 +1,96 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float128_t f16_to_f128( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ struct uint128 uiZ;
+ struct exp8_sig16 normExpSig;
+ union ui128_f128 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF128UI( &commonNaN );
+ } else {
+ uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
+ uiZ.v0 = 0;
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ.v64 = packToF128UI64( sign, 0, 0 );
+ uiZ.v0 = 0;
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
+ uiZ.v0 = 0;
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_to_f128M.c b/source/f16_to_f128M.c
new file mode 100644
index 0000000..a6f4249
--- /dev/null
+++ b/source/f16_to_f128M.c
@@ -0,0 +1,112 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void f16_to_f128M( float16_t a, float128_t *zPtr )
+{
+
+ *zPtr = f16_to_f128( a );
+
+}
+
+#else
+
+void f16_to_f128M( float16_t a, float128_t *zPtr )
+{
+ uint32_t *zWPtr;
+ union ui16_f16 uA;
+ uint16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint16_t frac;
+ struct commonNaN commonNaN;
+ uint32_t uiZ96;
+ struct exp8_sig16 normExpSig;
+ uint64_t frac64;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zWPtr = (uint32_t *) zPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ softfloat_commonNaNToF128M( &commonNaN, zWPtr );
+ return;
+ }
+ uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ96 = packToF128UI96( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ96 = packToF128UI96( sign, exp + 0x3FF0, (uint32_t) frac<<6 );
+ uiZ:
+ zWPtr[indexWord( 4, 3 )] = uiZ96;
+ zWPtr[indexWord( 4, 2 )] = 0;
+ zWPtr[indexWord( 4, 1 )] = 0;
+ zWPtr[indexWord( 4, 0 )] = 0;
+
+}
+
+#endif
+
diff --git a/source/f16_to_f32.c b/source/f16_to_f32.c
new file mode 100644
index 0000000..3fbc61d
--- /dev/null
+++ b/source/f16_to_f32.c
@@ -0,0 +1,93 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float32_t f16_to_f32( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ uint_fast32_t uiZ;
+ struct exp8_sig16 normExpSig;
+ union ui32_f32 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF32UI( &commonNaN );
+ } else {
+ uiZ = packToF32UI( sign, 0xFF, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ = packToF32UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_to_f64.c b/source/f16_to_f64.c
new file mode 100644
index 0000000..7b0de79
--- /dev/null
+++ b/source/f16_to_f64.c
@@ -0,0 +1,93 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float64_t f16_to_f64( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ uint_fast64_t uiZ;
+ struct exp8_sig16 normExpSig;
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF64UI( &commonNaN );
+ } else {
+ uiZ = packToF64UI( sign, 0x7FF, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ = packToF64UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f16_to_i32.c b/source/f16_to_i32.c
new file mode 100644
index 0000000..344c8a4
--- /dev/null
+++ b/source/f16_to_i32.c
@@ -0,0 +1,87 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+int_fast32_t f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? i32_fromNaN
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( 0 <= shiftDist ) {
+ sig32 <<= shiftDist;
+ return sign ? -sig32 : sig32;
+ }
+ shiftDist = exp - 0x0D;
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
+ }
+ return
+ softfloat_roundPackToI32(
+ sign, (uint_fast32_t) sig32, roundingMode, exact );
+
+}
+
diff --git a/source/f16_to_i32_r_minMag.c b/source/f16_to_i32_r_minMag.c
new file mode 100644
index 0000000..9bd13ec
--- /dev/null
+++ b/source/f16_to_i32_r_minMag.c
@@ -0,0 +1,88 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+int_fast32_t f16_to_i32_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ int_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? i32_fromNaN
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
+ if ( exact && (alignedSig & 0x3FF) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ alignedSig >>= 10;
+ return sign ? -alignedSig : alignedSig;
+
+}
+
diff --git a/source/f16_to_i64.c b/source/f16_to_i64.c
new file mode 100644
index 0000000..e0c064f
--- /dev/null
+++ b/source/f16_to_i64.c
@@ -0,0 +1,87 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+int_fast64_t f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? i64_fromNaN
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( 0 <= shiftDist ) {
+ sig32 <<= shiftDist;
+ return sign ? -sig32 : sig32;
+ }
+ shiftDist = exp - 0x0D;
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
+ }
+ return
+ softfloat_roundPackToI32(
+ sign, (uint_fast32_t) sig32, roundingMode, exact );
+
+}
+
diff --git a/source/f16_to_i64_r_minMag.c b/source/f16_to_i64_r_minMag.c
new file mode 100644
index 0000000..5f3c36b
--- /dev/null
+++ b/source/f16_to_i64_r_minMag.c
@@ -0,0 +1,88 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+int_fast64_t f16_to_i64_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ int_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? i64_fromNaN
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (int_fast32_t) (frac | 0x0400)<<shiftDist;
+ if ( exact && (alignedSig & 0x3FF) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ alignedSig >>= 10;
+ return sign ? -alignedSig : alignedSig;
+
+}
+
diff --git a/source/f16_to_ui32.c b/source/f16_to_ui32.c
new file mode 100644
index 0000000..1166014
--- /dev/null
+++ b/source/f16_to_ui32.c
@@ -0,0 +1,84 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+uint_fast32_t f16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ uint_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? ui32_fromNaN
+ : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( (0 <= shiftDist) && ! sign ) {
+ return sig32<<shiftDist;
+ }
+ shiftDist = exp - 0x0D;
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
+ }
+ return softfloat_roundPackToUI32( sign, sig32, roundingMode, exact );
+
+}
+
diff --git a/source/f16_to_ui32_r_minMag.c b/source/f16_to_ui32_r_minMag.c
new file mode 100644
index 0000000..91e5c6a
--- /dev/null
+++ b/source/f16_to_ui32_r_minMag.c
@@ -0,0 +1,87 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+uint_fast32_t f16_to_ui32_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ uint_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( sign || (exp == 0x1F) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? ui32_fromNaN
+ : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
+ if ( exact && (alignedSig & 0x3FF) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return alignedSig>>10;
+
+}
+
diff --git a/source/f16_to_ui64.c b/source/f16_to_ui64.c
new file mode 100644
index 0000000..6c5ef51
--- /dev/null
+++ b/source/f16_to_ui64.c
@@ -0,0 +1,84 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+uint_fast64_t f16_to_ui64( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ uint_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? ui64_fromNaN
+ : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( (0 <= shiftDist) && ! sign ) {
+ return sig32<<shiftDist;
+ }
+ shiftDist = exp - 0x0D;
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
+ }
+ return softfloat_roundPackToUI32( sign, sig32, roundingMode, exact );
+
+}
+
diff --git a/source/f16_to_ui64_r_minMag.c b/source/f16_to_ui64_r_minMag.c
new file mode 100644
index 0000000..13a2114
--- /dev/null
+++ b/source/f16_to_ui64_r_minMag.c
@@ -0,0 +1,87 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+uint_fast64_t f16_to_ui64_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ uint_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( sign || (exp == 0x1F) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? ui64_fromNaN
+ : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (uint_fast32_t) (frac | 0x0400)<<shiftDist;
+ if ( exact && (alignedSig & 0x3FF) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return alignedSig>>10;
+
+}
+
diff --git a/source/f32_add.c b/source/f32_add.c
index 5b5a09e..b671aa4 100644
--- a/source/f32_add.c
+++ b/source/f32_add.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,30 +44,26 @@ float32_t f32_add( float32_t a, float32_t b )
{
union ui32_f32 uA;
uint_fast32_t uiA;
- bool signA;
union ui32_f32 uB;
uint_fast32_t uiB;
- bool signB;
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
- float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t, bool );
+ float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
#endif
uA.f = a;
uiA = uA.ui;
- signA = signF32UI( uiA );
uB.f = b;
uiB = uB.ui;
- signB = signF32UI( uiB );
#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
- if ( signA == signB ) {
- return softfloat_addMagsF32( uiA, uiB, signA );
+ if ( signF32UI( uiA ^ uiB ) ) {
+ return softfloat_subMagsF32( uiA, uiB );
} else {
- return softfloat_subMagsF32( uiA, uiB, signA );
+ return softfloat_addMagsF32( uiA, uiB );
}
#else
magsFuncPtr =
- (signA == signB) ? softfloat_addMagsF32 : softfloat_subMagsF32;
- return (*magsFuncPtr)( uiA, uiB, signA );
+ signF32UI( uiA ^ uiB ) ? softfloat_subMagsF32 : softfloat_addMagsF32;
+ return (*magsFuncPtr)( uiA, uiB );
#endif
}
diff --git a/source/f32_div.c b/source/f32_div.c
index 2321d20..59211c2 100644
--- a/source/f32_div.c
+++ b/source/f32_div.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_eq.c b/source/f32_eq.c
index ee0918f..32a0598 100644
--- a/source/f32_eq.c
+++ b/source/f32_eq.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_eq_signaling.c b/source/f32_eq_signaling.c
index 52b1dd7..1520898 100644
--- a/source/f32_eq_signaling.c
+++ b/source/f32_eq_signaling.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_isSignalingNaN.c b/source/f32_isSignalingNaN.c
index 479c287..821e0c5 100644
--- a/source/f32_isSignalingNaN.c
+++ b/source/f32_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_le.c b/source/f32_le.c
index fb30c3c..17d5d25 100644
--- a/source/f32_le.c
+++ b/source/f32_le.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_le_quiet.c b/source/f32_le_quiet.c
index 3cb6378..259ac01 100644
--- a/source/f32_le_quiet.c
+++ b/source/f32_le_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_lt.c b/source/f32_lt.c
index 73af423..4c8881e 100644
--- a/source/f32_lt.c
+++ b/source/f32_lt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_lt_quiet.c b/source/f32_lt_quiet.c
index 0bab973..2338192 100644
--- a/source/f32_lt_quiet.c
+++ b/source/f32_lt_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_mul.c b/source/f32_mul.c
index 941eb39..5d5f9a8 100644
--- a/source/f32_mul.c
+++ b/source/f32_mul.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -60,6 +60,8 @@ float32_t f32_mul( float32_t a, float32_t b )
uint_fast32_t sigZ, uiZ;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
signA = signF32UI( uiA );
@@ -71,6 +73,8 @@ float32_t f32_mul( float32_t a, float32_t b )
expB = expF32UI( uiB );
sigB = fracF32UI( uiB );
signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( expA == 0xFF ) {
if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN;
magBits = expB | sigB;
@@ -81,6 +85,8 @@ float32_t f32_mul( float32_t a, float32_t b )
magBits = expA | sigA;
goto infArg;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! expA ) {
if ( ! sigA ) goto zero;
normExpSig = softfloat_normSubnormalF32Sig( sigA );
@@ -93,6 +99,8 @@ float32_t f32_mul( float32_t a, float32_t b )
expB = normExpSig.exp;
sigB = normExpSig.sig;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expZ = expA + expB - 0x7F;
sigA = (sigA | 0x00800000)<<7;
sigB = (sigB | 0x00800000)<<8;
@@ -102,9 +110,13 @@ float32_t f32_mul( float32_t a, float32_t b )
sigZ <<= 1;
}
return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
propagateNaN:
uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
infArg:
if ( ! magBits ) {
softfloat_raiseFlags( softfloat_flag_invalid );
@@ -113,6 +125,8 @@ float32_t f32_mul( float32_t a, float32_t b )
uiZ = packToF32UI( signZ, 0xFF, 0 );
}
goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
zero:
uiZ = packToF32UI( signZ, 0, 0 );
uiZ:
diff --git a/source/f32_mulAdd.c b/source/f32_mulAdd.c
index 5bf77fe..35d4c9d 100644
--- a/source/f32_mulAdd.c
+++ b/source/f32_mulAdd.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_rem.c b/source/f32_rem.c
index b1997ef..9a0cd8e 100644
--- a/source/f32_rem.c
+++ b/source/f32_rem.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_roundToInt.c b/source/f32_roundToInt.c
index 314747e..00577f8 100644
--- a/source/f32_roundToInt.c
+++ b/source/f32_roundToInt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f32_sqrt.c b/source/f32_sqrt.c
index d0b489c..ab9c562 100644
--- a/source/f32_sqrt.c
+++ b/source/f32_sqrt.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -94,13 +94,13 @@ float32_t f32_sqrt( float32_t a )
((uint_fast64_t) sigA * softfloat_approxRecipSqrt32_1( expA, sigA ))
>>32;
if ( expA ) sigZ >>= 1;
- sigZ += 2;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
+ sigZ += 2;
if ( (sigZ & 0x3F) < 2 ) {
shiftedSigZ = sigZ>>2;
negRem = shiftedSigZ * shiftedSigZ;
- sigZ = shiftedSigZ<<2;
+ sigZ &= ~3;
if ( negRem & 0x80000000 ) {
sigZ |= 1;
} else {
diff --git a/source/f32_sub.c b/source/f32_sub.c
index eae436c..a9a03ea 100644
--- a/source/f32_sub.c
+++ b/source/f32_sub.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,30 +44,26 @@ float32_t f32_sub( float32_t a, float32_t b )
{
union ui32_f32 uA;
uint_fast32_t uiA;
- bool signA;
union ui32_f32 uB;
uint_fast32_t uiB;
- bool signB;
#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
- float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t, bool );
+ float32_t (*magsFuncPtr)( uint_fast32_t, uint_fast32_t );
#endif
uA.f = a;
uiA = uA.ui;
- signA = signF32UI( uiA );
uB.f = b;
uiB = uB.ui;
- signB = signF32UI( uiB );
#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
- if ( signA == signB ) {
- return softfloat_subMagsF32( uiA, uiB, signA );
+ if ( signF32UI( uiA ^ uiB ) ) {
+ return softfloat_addMagsF32( uiA, uiB );
} else {
- return softfloat_addMagsF32( uiA, uiB, signA );
+ return softfloat_subMagsF32( uiA, uiB );
}
#else
magsFuncPtr =
- (signA == signB) ? softfloat_subMagsF32 : softfloat_addMagsF32;
- return (*magsFuncPtr)( uiA, uiB, signA );
+ signF32UI( uiA ^ uiB ) ? softfloat_addMagsF32 : softfloat_subMagsF32;
+ return (*magsFuncPtr)( uiA, uiB );
#endif
}
diff --git a/source/f32_to_extF80.c b/source/f32_to_extF80.c
index 7e7b279..4bf207d 100644
--- a/source/f32_to_extF80.c
+++ b/source/f32_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,7 +47,7 @@ extFloat80_t f32_to_extF80( float32_t a )
uint_fast32_t uiA;
bool sign;
int_fast16_t exp;
- uint_fast32_t sig;
+ uint_fast32_t frac;
struct commonNaN commonNaN;
struct uint128 uiZ;
uint_fast16_t uiZ64;
@@ -55,13 +55,17 @@ extFloat80_t f32_to_extF80( float32_t a )
struct exp16_sig32 normExpSig;
union { struct extFloat80M s; extFloat80_t f; } uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF32UI( uiA );
exp = expF32UI( uiA );
- sig = fracF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0xFF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f32UIToCommonNaN( uiA, &commonNaN );
uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
uiZ64 = uiZ.v64;
@@ -72,18 +76,22 @@ extFloat80_t f32_to_extF80( float32_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ64 = packToExtF80UI64( sign, 0 );
uiZ0 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF32Sig( sig );
+ normExpSig = softfloat_normSubnormalF32Sig( frac );
exp = normExpSig.exp;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
- uiZ0 = (uint_fast64_t) (sig | 0x00800000)<<40;
+ uiZ0 = (uint_fast64_t) (frac | 0x00800000)<<40;
uiZ:
uZ.s.signExp = uiZ64;
uZ.s.signif = uiZ0;
diff --git a/source/f32_to_extF80M.c b/source/f32_to_extF80M.c
index 172f7b9..488c8b1 100644
--- a/source/f32_to_extF80M.c
+++ b/source/f32_to_extF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -59,43 +59,51 @@ void f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
uint32_t uiA;
bool sign;
int_fast16_t exp;
- uint32_t sig;
+ uint32_t frac;
struct commonNaN commonNaN;
uint_fast16_t uiZ64;
- uint64_t uiZ0;
+ uint32_t uiZ32;
struct exp16_sig32 normExpSig;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
zSPtr = (struct extFloat80M *) zPtr;
uA.f = a;
uiA = uA.ui;
sign = signF32UI( uiA );
exp = expF32UI( uiA );
- sig = fracF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0xFF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f32UIToCommonNaN( uiA, &commonNaN );
softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
return;
}
uiZ64 = packToExtF80UI64( sign, 0x7FFF );
- uiZ0 = UINT64_C( 0x8000000000000000 );
+ uiZ32 = 0x80000000;
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ64 = packToExtF80UI64( sign, 0 );
- uiZ0 = 0;
+ uiZ32 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF32Sig( sig );
+ normExpSig = softfloat_normSubnormalF32Sig( frac );
exp = normExpSig.exp;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ64 = packToExtF80UI64( sign, exp + 0x3F80 );
- uiZ0 = UINT64_C( 0x8000000000000000 ) | (uint64_t) sig<<40;
+ uiZ32 = 0x80000000 | (uint32_t) frac<<8;
uiZ:
zSPtr->signExp = uiZ64;
- zSPtr->signif = uiZ0;
+ zSPtr->signif = (uint64_t) uiZ32<<32;
}
diff --git a/source/f32_to_f128.c b/source/f32_to_f128.c
index f657d5b..202e096 100644
--- a/source/f32_to_f128.c
+++ b/source/f32_to_f128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,19 +47,23 @@ float128_t f32_to_f128( float32_t a )
uint_fast32_t uiA;
bool sign;
int_fast16_t exp;
- uint_fast32_t sig;
+ uint_fast32_t frac;
struct commonNaN commonNaN;
struct uint128 uiZ;
struct exp16_sig32 normExpSig;
union ui128_f128 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF32UI( uiA );
exp = expF32UI( uiA );
- sig = fracF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0xFF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f32UIToCommonNaN( uiA, &commonNaN );
uiZ = softfloat_commonNaNToF128UI( &commonNaN );
} else {
@@ -68,17 +72,21 @@ float128_t f32_to_f128( float32_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ.v64 = packToF128UI64( sign, 0, 0 );
uiZ.v0 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF32Sig( sig );
+ normExpSig = softfloat_normSubnormalF32Sig( frac );
exp = normExpSig.exp - 1;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
- uiZ.v64 = packToF128UI64( sign, exp + 0x3F80, (uint_fast64_t) sig<<25 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ.v64 = packToF128UI64( sign, exp + 0x3F80, (uint_fast64_t) frac<<25 );
uiZ.v0 = 0;
uiZ:
uZ.ui = uiZ;
diff --git a/source/f32_to_f128M.c b/source/f32_to_f128M.c
index da0b56a..3049f0e 100644
--- a/source/f32_to_f128M.c
+++ b/source/f32_to_f128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -59,21 +59,27 @@ void f32_to_f128M( float32_t a, float128_t *zPtr )
uint32_t uiA;
bool sign;
int_fast16_t exp;
- uint32_t sig, uiZ64;
+ uint32_t frac, uiZ64;
struct commonNaN commonNaN;
uint32_t uiZ96;
struct exp16_sig32 normExpSig;
- uint64_t sig64;
+ uint64_t frac64;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
zWPtr = (uint32_t *) zPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF32UI( uiA );
exp = expF32UI( uiA );
- sig = fracF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ64 = 0;
if ( exp == 0xFF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f32UIToCommonNaN( uiA, &commonNaN );
softfloat_commonNaNToF128M( &commonNaN, zWPtr );
return;
@@ -81,18 +87,22 @@ void f32_to_f128M( float32_t a, float128_t *zPtr )
uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ96 = packToF128UI96( sign, 0, 0 );
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF32Sig( sig );
+ normExpSig = softfloat_normSubnormalF32Sig( frac );
exp = normExpSig.exp - 1;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
- sig64 = (uint64_t) sig<<25;
- uiZ96 = packToF128UI96( sign, exp + 0x3F80, sig64>>32 );
- uiZ64 = sig64;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac64 = (uint64_t) frac<<25;
+ uiZ96 = packToF128UI96( sign, exp + 0x3F80, frac64>>32 );
+ uiZ64 = frac64;
uiZ:
zWPtr[indexWord( 4, 3 )] = uiZ96;
zWPtr[indexWord( 4, 2 )] = uiZ64;
diff --git a/source/f32_to_f16.c b/source/f32_to_f16.c
new file mode 100644
index 0000000..e559082
--- /dev/null
+++ b/source/f32_to_f16.c
@@ -0,0 +1,88 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t f32_to_f16( float32_t a )
+{
+ union ui32_f32 uA;
+ uint_fast32_t uiA;
+ bool sign;
+ int_fast16_t exp;
+ uint_fast32_t frac;
+ struct commonNaN commonNaN;
+ uint_fast16_t uiZ, frac16;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF32UI( uiA );
+ exp = expF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0xFF ) {
+ if ( frac ) {
+ softfloat_f32UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
+ } else {
+ uiZ = packToF16UI( sign, 0x1F, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac16 = frac>>9 | ((frac & 0x1FF) != 0);
+ if ( ! (exp | frac16) ) {
+ uiZ = packToF16UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ return softfloat_roundPackToF16( sign, exp - 0x71, frac16 | 0x4000 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f32_to_f64.c b/source/f32_to_f64.c
index 30b0923..009b381 100644
--- a/source/f32_to_f64.c
+++ b/source/f32_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,19 +47,23 @@ float64_t f32_to_f64( float32_t a )
uint_fast32_t uiA;
bool sign;
int_fast16_t exp;
- uint_fast32_t sig;
+ uint_fast32_t frac;
struct commonNaN commonNaN;
uint_fast64_t uiZ;
struct exp16_sig32 normExpSig;
union ui64_f64 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF32UI( uiA );
exp = expF32UI( uiA );
- sig = fracF32UI( uiA );
+ frac = fracF32UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0xFF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f32UIToCommonNaN( uiA, &commonNaN );
uiZ = softfloat_commonNaNToF64UI( &commonNaN );
} else {
@@ -67,16 +71,20 @@ float64_t f32_to_f64( float32_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ = packToF64UI( sign, 0, 0 );
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF32Sig( sig );
+ normExpSig = softfloat_normSubnormalF32Sig( frac );
exp = normExpSig.exp - 1;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
- uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) sig<<29 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = packToF64UI( sign, exp + 0x380, (uint_fast64_t) frac<<29 );
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f32_to_i32.c b/source/f32_to_i32.c
index c80649a..cf2e0b0 100644
--- a/source/f32_to_i32.c
+++ b/source/f32_to_i32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -76,7 +76,7 @@ int_fast32_t f32_to_i32( float32_t a, uint_fast8_t roundingMode, bool exact )
*------------------------------------------------------------------------*/
if ( exp ) sig |= 0x00800000;
sig64 = (uint_fast64_t) sig<<32;
- shiftDist = 0xAF - exp;
+ shiftDist = 0xAA - exp;
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
return softfloat_roundPackToI32( sign, sig64, roundingMode, exact );
diff --git a/source/f32_to_i32_r_minMag.c b/source/f32_to_i32_r_minMag.c
index d2e4b92..9693f8a 100644
--- a/source/f32_to_i32_r_minMag.c
+++ b/source/f32_to_i32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f32_to_i64.c b/source/f32_to_i64.c
index b354f6c..b26b9df 100644
--- a/source/f32_to_i64.c
+++ b/source/f32_to_i64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f32_to_i64_r_minMag.c b/source/f32_to_i64_r_minMag.c
index af2b28b..f1d871e 100644
--- a/source/f32_to_i64_r_minMag.c
+++ b/source/f32_to_i64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f32_to_ui32.c b/source/f32_to_ui32.c
index 1979dd5..638bdce 100644
--- a/source/f32_to_ui32.c
+++ b/source/f32_to_ui32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -76,7 +76,7 @@ uint_fast32_t f32_to_ui32( float32_t a, uint_fast8_t roundingMode, bool exact )
*------------------------------------------------------------------------*/
if ( exp ) sig |= 0x00800000;
sig64 = (uint_fast64_t) sig<<32;
- shiftDist = 0xAF - exp;
+ shiftDist = 0xAA - exp;
if ( 0 < shiftDist ) sig64 = softfloat_shiftRightJam64( sig64, shiftDist );
return softfloat_roundPackToUI32( sign, sig64, roundingMode, exact );
diff --git a/source/f32_to_ui32_r_minMag.c b/source/f32_to_ui32_r_minMag.c
index 9979b2c..f4495d2 100644
--- a/source/f32_to_ui32_r_minMag.c
+++ b/source/f32_to_ui32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f32_to_ui64.c b/source/f32_to_ui64.c
index 6be8537..7cf3366 100644
--- a/source/f32_to_ui64.c
+++ b/source/f32_to_ui64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f32_to_ui64_r_minMag.c b/source/f32_to_ui64_r_minMag.c
index 0d5fe5b..05319b9 100644
--- a/source/f32_to_ui64_r_minMag.c
+++ b/source/f32_to_ui64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f64_add.c b/source/f64_add.c
index 5bbb1b5..1e575f0 100644
--- a/source/f64_add.c
+++ b/source/f64_add.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_div.c b/source/f64_div.c
index 96523f0..13b037d 100644
--- a/source/f64_div.c
+++ b/source/f64_div.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_eq.c b/source/f64_eq.c
index 6d69e03..d756d9f 100644
--- a/source/f64_eq.c
+++ b/source/f64_eq.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_eq_signaling.c b/source/f64_eq_signaling.c
index 2f77bbd..c3a3cfb 100644
--- a/source/f64_eq_signaling.c
+++ b/source/f64_eq_signaling.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_isSignalingNaN.c b/source/f64_isSignalingNaN.c
index 2858ded..efcc16b 100644
--- a/source/f64_isSignalingNaN.c
+++ b/source/f64_isSignalingNaN.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_le.c b/source/f64_le.c
index 7462215..563479b 100644
--- a/source/f64_le.c
+++ b/source/f64_le.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_le_quiet.c b/source/f64_le_quiet.c
index 907c5ec..f361f99 100644
--- a/source/f64_le_quiet.c
+++ b/source/f64_le_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_lt.c b/source/f64_lt.c
index 902701f..311ca77 100644
--- a/source/f64_lt.c
+++ b/source/f64_lt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_lt_quiet.c b/source/f64_lt_quiet.c
index 5d20c48..195c79b 100644
--- a/source/f64_lt_quiet.c
+++ b/source/f64_lt_quiet.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_mul.c b/source/f64_mul.c
index 78c4421..3f50d62 100644
--- a/source/f64_mul.c
+++ b/source/f64_mul.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_mulAdd.c b/source/f64_mulAdd.c
index 37bd999..c484a81 100644
--- a/source/f64_mulAdd.c
+++ b/source/f64_mulAdd.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_rem.c b/source/f64_rem.c
index 8ae87fc..ba1e83d 100644
--- a/source/f64_rem.c
+++ b/source/f64_rem.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_roundToInt.c b/source/f64_roundToInt.c
index 94fe40d..37e2a44 100644
--- a/source/f64_roundToInt.c
+++ b/source/f64_roundToInt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_sqrt.c b/source/f64_sqrt.c
index b65c150..a580f96 100644
--- a/source/f64_sqrt.c
+++ b/source/f64_sqrt.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_sub.c b/source/f64_sub.c
index 0169ef8..9bafe75 100644
--- a/source/f64_sub.c
+++ b/source/f64_sub.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/f64_to_extF80.c b/source/f64_to_extF80.c
index 2ae4e16..f1d3401 100644
--- a/source/f64_to_extF80.c
+++ b/source/f64_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,7 +47,7 @@ extFloat80_t f64_to_extF80( float64_t a )
uint_fast64_t uiA;
bool sign;
int_fast16_t exp;
- uint_fast64_t sig;
+ uint_fast64_t frac;
struct commonNaN commonNaN;
struct uint128 uiZ;
uint_fast16_t uiZ64;
@@ -55,13 +55,17 @@ extFloat80_t f64_to_extF80( float64_t a )
struct exp16_sig64 normExpSig;
union { struct extFloat80M s; extFloat80_t f; } uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF64UI( uiA );
exp = expF64UI( uiA );
- sig = fracF64UI( uiA );
+ frac = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f64UIToCommonNaN( uiA, &commonNaN );
uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
uiZ64 = uiZ.v64;
@@ -72,18 +76,22 @@ extFloat80_t f64_to_extF80( float64_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ64 = packToExtF80UI64( sign, 0 );
uiZ0 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF64Sig( sig );
+ normExpSig = softfloat_normSubnormalF64Sig( frac );
exp = normExpSig.exp;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
- uiZ0 = (sig | UINT64_C( 0x0010000000000000 ))<<11;
+ uiZ0 = (frac | UINT64_C( 0x0010000000000000 ))<<11;
uiZ:
uZ.s.signExp = uiZ64;
uZ.s.signif = uiZ0;
diff --git a/source/f64_to_extF80M.c b/source/f64_to_extF80M.c
index 9c08cc5..673c35a 100644
--- a/source/f64_to_extF80M.c
+++ b/source/f64_to_extF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -59,20 +59,24 @@ void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
uint64_t uiA;
bool sign;
int_fast16_t exp;
- uint64_t sig;
+ uint64_t frac;
struct commonNaN commonNaN;
uint_fast16_t uiZ64;
uint64_t uiZ0;
struct exp16_sig64 normExpSig;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
zSPtr = (struct extFloat80M *) zPtr;
uA.f = a;
uiA = uA.ui;
sign = signF64UI( uiA );
exp = expF64UI( uiA );
- sig = fracF64UI( uiA );
+ frac = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f64UIToCommonNaN( uiA, &commonNaN );
softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
return;
@@ -81,18 +85,22 @@ void f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
uiZ0 = UINT64_C( 0x8000000000000000 );
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ64 = packToExtF80UI64( sign, 0 );
uiZ0 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF64Sig( sig );
+ normExpSig = softfloat_normSubnormalF64Sig( frac );
exp = normExpSig.exp;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uiZ64 = packToExtF80UI64( sign, exp + 0x3C00 );
- uiZ0 = UINT64_C( 0x8000000000000000 ) | sig<<11;
+ uiZ0 = UINT64_C( 0x8000000000000000 ) | frac<<11;
uiZ:
zSPtr->signExp = uiZ64;
zSPtr->signif = uiZ0;
diff --git a/source/f64_to_f128.c b/source/f64_to_f128.c
index 2376327..b2f4c99 100644
--- a/source/f64_to_f128.c
+++ b/source/f64_to_f128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,20 +47,24 @@ float128_t f64_to_f128( float64_t a )
uint_fast64_t uiA;
bool sign;
int_fast16_t exp;
- uint_fast64_t sig;
+ uint_fast64_t frac;
struct commonNaN commonNaN;
struct uint128 uiZ;
struct exp16_sig64 normExpSig;
- struct uint128 sig128;
+ struct uint128 frac128;
union ui128_f128 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF64UI( uiA );
exp = expF64UI( uiA );
- sig = fracF64UI( uiA );
+ frac = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f64UIToCommonNaN( uiA, &commonNaN );
uiZ = softfloat_commonNaNToF128UI( &commonNaN );
} else {
@@ -69,19 +73,23 @@ float128_t f64_to_f128( float64_t a )
}
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ.v64 = packToF128UI64( sign, 0, 0 );
uiZ.v0 = 0;
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF64Sig( sig );
+ normExpSig = softfloat_normSubnormalF64Sig( frac );
exp = normExpSig.exp - 1;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
- sig128 = softfloat_shortShiftLeft128( 0, sig, 60 );
- uiZ.v64 = packToF128UI64( sign, exp + 0x3C00, sig128.v64 );
- uiZ.v0 = sig128.v0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac128 = softfloat_shortShiftLeft128( 0, frac, 60 );
+ uiZ.v64 = packToF128UI64( sign, exp + 0x3C00, frac128.v64 );
+ uiZ.v0 = frac128.v0;
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f64_to_f128M.c b/source/f64_to_f128M.c
index f793c3a..3aa8ec7 100644
--- a/source/f64_to_f128M.c
+++ b/source/f64_to_f128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
@@ -59,7 +59,7 @@ void f64_to_f128M( float64_t a, float128_t *zPtr )
uint64_t uiA;
bool sign;
int_fast16_t exp;
- uint64_t sig;
+ uint64_t frac;
struct commonNaN commonNaN;
uint32_t uiZ96;
struct exp16_sig64 normExpSig;
@@ -73,12 +73,12 @@ void f64_to_f128M( float64_t a, float128_t *zPtr )
uiA = uA.ui;
sign = signF64UI( uiA );
exp = expF64UI( uiA );
- sig = fracF64UI( uiA );
+ frac = fracF64UI( uiA );
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
zWPtr[indexWord( 4, 0 )] = 0;
if ( exp == 0x7FF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f64UIToCommonNaN( uiA, &commonNaN );
softfloat_commonNaNToF128M( &commonNaN, zWPtr );
return;
@@ -89,20 +89,20 @@ void f64_to_f128M( float64_t a, float128_t *zPtr )
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( ! exp ) {
- if ( ! sig ) {
+ if ( ! frac ) {
uiZ96 = packToF128UI96( sign, 0, 0 );
goto uiZ;
}
- normExpSig = softfloat_normSubnormalF64Sig( sig );
+ normExpSig = softfloat_normSubnormalF64Sig( frac );
exp = normExpSig.exp - 1;
- sig = normExpSig.sig;
+ frac = normExpSig.sig;
}
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- zWPtr[indexWord( 4, 1 )] = (uint32_t) sig<<28;
- sig >>= 4;
- zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp + 0x3C00, sig>>32 );
- zWPtr[indexWord( 4, 2 )] = sig;
+ zWPtr[indexWord( 4, 1 )] = (uint32_t) frac<<28;
+ frac >>= 4;
+ zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp + 0x3C00, frac>>32 );
+ zWPtr[indexWord( 4, 2 )] = frac;
return;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
diff --git a/source/f64_to_f16.c b/source/f64_to_f16.c
new file mode 100644
index 0000000..61706a2
--- /dev/null
+++ b/source/f64_to_f16.c
@@ -0,0 +1,88 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t f64_to_f16( float64_t a )
+{
+ union ui64_f64 uA;
+ uint_fast64_t uiA;
+ bool sign;
+ int_fast16_t exp;
+ uint_fast64_t frac;
+ struct commonNaN commonNaN;
+ uint_fast16_t uiZ, frac16;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF64UI( uiA );
+ exp = expF64UI( uiA );
+ frac = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x7FF ) {
+ if ( frac ) {
+ softfloat_f64UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF16UI( &commonNaN );
+ } else {
+ uiZ = packToF16UI( sign, 0x1F, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac16 = softfloat_shortShiftRightJam64( frac, 38 );
+ if ( ! (exp | frac16) ) {
+ uiZ = packToF16UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ return softfloat_roundPackToF16( sign, exp - 0x3F1, frac16 | 0x4000 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/f64_to_f32.c b/source/f64_to_f32.c
index c08b964..947470c 100644
--- a/source/f64_to_f32.c
+++ b/source/f64_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -47,18 +47,22 @@ float32_t f64_to_f32( float64_t a )
uint_fast64_t uiA;
bool sign;
int_fast16_t exp;
- uint_fast64_t sig;
+ uint_fast64_t frac;
struct commonNaN commonNaN;
- uint_fast32_t uiZ, sig32;
+ uint_fast32_t uiZ, frac32;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
uA.f = a;
uiA = uA.ui;
sign = signF64UI( uiA );
exp = expF64UI( uiA );
- sig = fracF64UI( uiA );
+ frac = fracF64UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( exp == 0x7FF ) {
- if ( sig ) {
+ if ( frac ) {
softfloat_f64UIToCommonNaN( uiA, &commonNaN );
uiZ = softfloat_commonNaNToF32UI( &commonNaN );
} else {
@@ -66,12 +70,16 @@ float32_t f64_to_f32( float64_t a )
}
goto uiZ;
}
- sig32 = softfloat_shortShiftRightJam64( sig, 22 );
- if ( ! (exp | sig32) ) {
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ frac32 = softfloat_shortShiftRightJam64( frac, 22 );
+ if ( ! (exp | frac32) ) {
uiZ = packToF32UI( sign, 0, 0 );
goto uiZ;
}
- return softfloat_roundPackToF32( sign, exp - 0x381, sig32 | 0x40000000 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ return softfloat_roundPackToF32( sign, exp - 0x381, frac32 | 0x40000000 );
uiZ:
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/f64_to_i32.c b/source/f64_to_i32.c
index b41aac6..0a9525a 100644
--- a/source/f64_to_i32.c
+++ b/source/f64_to_i32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -74,7 +74,7 @@ int_fast32_t f64_to_i32( float64_t a, uint_fast8_t roundingMode, bool exact )
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
- shiftDist = 0x42C - exp;
+ shiftDist = 0x427 - exp;
if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
return softfloat_roundPackToI32( sign, sig, roundingMode, exact );
diff --git a/source/f64_to_i32_r_minMag.c b/source/f64_to_i32_r_minMag.c
index ae3171e..d5fa546 100644
--- a/source/f64_to_i32_r_minMag.c
+++ b/source/f64_to_i32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f64_to_i64.c b/source/f64_to_i64.c
index 58cb45b..ef8cf13 100644
--- a/source/f64_to_i64.c
+++ b/source/f64_to_i64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f64_to_i64_r_minMag.c b/source/f64_to_i64_r_minMag.c
index 003e165..46756a1 100644
--- a/source/f64_to_i64_r_minMag.c
+++ b/source/f64_to_i64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f64_to_ui32.c b/source/f64_to_ui32.c
index 6027c2f..9970d59 100644
--- a/source/f64_to_ui32.c
+++ b/source/f64_to_ui32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -74,7 +74,7 @@ uint_fast32_t f64_to_ui32( float64_t a, uint_fast8_t roundingMode, bool exact )
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
if ( exp ) sig |= UINT64_C( 0x0010000000000000 );
- shiftDist = 0x42C - exp;
+ shiftDist = 0x427 - exp;
if ( 0 < shiftDist ) sig = softfloat_shiftRightJam64( sig, shiftDist );
return softfloat_roundPackToUI32( sign, sig, roundingMode, exact );
diff --git a/source/f64_to_ui32_r_minMag.c b/source/f64_to_ui32_r_minMag.c
index 8d0dc71..6813a1c 100644
--- a/source/f64_to_ui32_r_minMag.c
+++ b/source/f64_to_ui32_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f64_to_ui64.c b/source/f64_to_ui64.c
index 636d70c..602da22 100644
--- a/source/f64_to_ui64.c
+++ b/source/f64_to_ui64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/f64_to_ui64_r_minMag.c b/source/f64_to_ui64_r_minMag.c
index e54c930..d769b3d 100644
--- a/source/f64_to_ui64_r_minMag.c
+++ b/source/f64_to_ui64_r_minMag.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/i32_to_extF80.c b/source/i32_to_extF80.c
index 18c7588..1c7a255 100644
--- a/source/i32_to_extF80.c
+++ b/source/i32_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -45,7 +45,7 @@ extFloat80_t i32_to_extF80( int32_t a )
uint_fast16_t uiZ64;
uint_fast32_t absA;
bool sign;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union { struct extFloat80M s; extFloat80_t f; } uZ;
uiZ64 = 0;
@@ -53,9 +53,9 @@ extFloat80_t i32_to_extF80( int32_t a )
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
- shiftCount = softfloat_countLeadingZeros32( absA );
- uiZ64 = packToExtF80UI64( sign, 0x401E - shiftCount );
- absA <<= shiftCount;
+ shiftDist = softfloat_countLeadingZeros32( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
+ absA <<= shiftDist;
}
uZ.s.signExp = uiZ64;
uZ.s.signif = (uint_fast64_t) absA<<32;
diff --git a/source/i32_to_extF80M.c b/source/i32_to_extF80M.c
index f77d9db..a741d85 100644
--- a/source/i32_to_extF80M.c
+++ b/source/i32_to_extF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -57,7 +57,7 @@ void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
uint64_t sigZ;
bool sign;
uint32_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
zSPtr = (struct extFloat80M *) zPtr;
uiZ64 = 0;
@@ -65,9 +65,9 @@ void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint32_t) a : (uint32_t) a;
- shiftCount = softfloat_countLeadingZeros32( absA );
- uiZ64 = packToExtF80UI64( sign, 0x401E - shiftCount );
- sigZ = (uint64_t) (absA<<shiftCount)<<32;
+ shiftDist = softfloat_countLeadingZeros32( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
+ sigZ = (uint64_t) (absA<<shiftDist)<<32;
}
zSPtr->signExp = uiZ64;
zSPtr->signif = sigZ;
diff --git a/source/i32_to_f128.c b/source/i32_to_f128.c
index 5cb5e68..ad557c4 100644
--- a/source/i32_to_f128.c
+++ b/source/i32_to_f128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,17 +44,17 @@ float128_t i32_to_f128( int32_t a )
uint_fast64_t uiZ64;
bool sign;
uint_fast32_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui128_f128 uZ;
uiZ64 = 0;
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
- shiftCount = softfloat_countLeadingZeros32( absA ) + 17;
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
uiZ64 =
packToF128UI64(
- sign, 0x402E - shiftCount, (uint_fast64_t) absA<<shiftCount );
+ sign, 0x402E - shiftDist, (uint_fast64_t) absA<<shiftDist );
}
uZ.ui.v64 = uiZ64;
uZ.ui.v0 = 0;
diff --git a/source/i32_to_f128M.c b/source/i32_to_f128M.c
index e02a0d6..f666f5b 100644
--- a/source/i32_to_f128M.c
+++ b/source/i32_to_f128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@ void i32_to_f128M( int32_t a, float128_t *zPtr )
uint32_t uiZ96, uiZ64;
bool sign;
uint32_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
uint64_t normAbsA;
zWPtr = (uint32_t *) zPtr;
@@ -65,9 +65,9 @@ void i32_to_f128M( int32_t a, float128_t *zPtr )
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint32_t) a : (uint32_t) a;
- shiftCount = softfloat_countLeadingZeros32( absA ) + 17;
- normAbsA = (uint64_t) absA<<shiftCount;
- uiZ96 = packToF128UI96( sign, 0x402E - shiftCount, normAbsA>>32 );
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
+ normAbsA = (uint64_t) absA<<shiftDist;
+ uiZ96 = packToF128UI96( sign, 0x402E - shiftDist, normAbsA>>32 );
uiZ64 = normAbsA;
}
zWPtr[indexWord( 4, 3 )] = uiZ96;
diff --git a/source/i32_to_f16.c b/source/i32_to_f16.c
new file mode 100644
index 0000000..e1b4f6b
--- /dev/null
+++ b/source/i32_to_f16.c
@@ -0,0 +1,71 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t i32_to_f16( int32_t a )
+{
+ bool sign;
+ uint_fast32_t absA;
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ sign = (a < 0);
+ absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
+ : 0;
+ return u.f;
+ } else {
+ shiftDist += 4;
+ sig =
+ (shiftDist < 0)
+ ? absA>>(-shiftDist)
+ | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
+ : (uint_fast16_t) absA<<shiftDist;
+ return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
+ }
+
+}
+
diff --git a/source/i32_to_f32.c b/source/i32_to_f32.c
index bfe8ace..b9d022f 100644
--- a/source/i32_to_f32.c
+++ b/source/i32_to_f32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/i32_to_f64.c b/source/i32_to_f64.c
index ac17f78..fc9a9ef 100644
--- a/source/i32_to_f64.c
+++ b/source/i32_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -45,7 +45,7 @@ float64_t i32_to_f64( int32_t a )
uint_fast64_t uiZ;
bool sign;
uint_fast32_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui64_f64 uZ;
if ( ! a ) {
@@ -53,10 +53,10 @@ float64_t i32_to_f64( int32_t a )
} else {
sign = (a < 0);
absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
- shiftCount = softfloat_countLeadingZeros32( absA ) + 21;
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
uiZ =
packToF64UI(
- sign, 0x432 - shiftCount, (uint_fast64_t) absA<<shiftCount );
+ sign, 0x432 - shiftDist, (uint_fast64_t) absA<<shiftDist );
}
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/i64_to_extF80.c b/source/i64_to_extF80.c
index b655342..9b69f9d 100644
--- a/source/i64_to_extF80.c
+++ b/source/i64_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -45,7 +45,7 @@ extFloat80_t i64_to_extF80( int64_t a )
uint_fast16_t uiZ64;
uint_fast64_t absA;
bool sign;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union { struct extFloat80M s; extFloat80_t f; } uZ;
uiZ64 = 0;
@@ -53,9 +53,9 @@ extFloat80_t i64_to_extF80( int64_t a )
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
- shiftCount = softfloat_countLeadingZeros64( absA );
- uiZ64 = packToExtF80UI64( sign, 0x403E - shiftCount );
- absA <<= shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
+ absA <<= shiftDist;
}
uZ.s.signExp = uiZ64;
uZ.s.signif = absA;
diff --git a/source/i64_to_extF80M.c b/source/i64_to_extF80M.c
index 2d1383e..7e7a142 100644
--- a/source/i64_to_extF80M.c
+++ b/source/i64_to_extF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -57,7 +57,7 @@ void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
uint64_t sigZ;
bool sign;
uint64_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
zSPtr = (struct extFloat80M *) zPtr;
uiZ64 = 0;
@@ -65,9 +65,9 @@ void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint64_t) a : (uint64_t) a;
- shiftCount = softfloat_countLeadingZeros64( absA );
- uiZ64 = packToExtF80UI64( sign, 0x403E - shiftCount );
- sigZ = absA<<shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
+ sigZ = absA<<shiftDist;
}
zSPtr->signExp = uiZ64;
zSPtr->signif = sigZ;
diff --git a/source/i64_to_f128.c b/source/i64_to_f128.c
index 2ca9953..b55685b 100644
--- a/source/i64_to_f128.c
+++ b/source/i64_to_f128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,7 +44,7 @@ float128_t i64_to_f128( int64_t a )
uint_fast64_t uiZ64, uiZ0;
bool sign;
uint_fast64_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct uint128 zSig;
union ui128_f128 uZ;
@@ -54,14 +54,14 @@ float128_t i64_to_f128( int64_t a )
} else {
sign = (a < 0);
absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
- shiftCount = softfloat_countLeadingZeros64( absA ) + 49;
- if ( 64 <= shiftCount ) {
- zSig.v64 = absA<<(shiftCount - 64);
+ shiftDist = softfloat_countLeadingZeros64( absA ) + 49;
+ if ( 64 <= shiftDist ) {
+ zSig.v64 = absA<<(shiftDist - 64);
zSig.v0 = 0;
} else {
- zSig = softfloat_shortShiftLeft128( 0, absA, shiftCount );
+ zSig = softfloat_shortShiftLeft128( 0, absA, shiftDist );
}
- uiZ64 = packToF128UI64( sign, 0x406E - shiftCount, zSig.v64 );
+ uiZ64 = packToF128UI64( sign, 0x406E - shiftDist, zSig.v64 );
uiZ0 = zSig.v0;
}
uZ.ui.v64 = uiZ64;
diff --git a/source/i64_to_f128M.c b/source/i64_to_f128M.c
index 435d1e3..a8b6359 100644
--- a/source/i64_to_f128M.c
+++ b/source/i64_to_f128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@ void i64_to_f128M( int64_t a, float128_t *zPtr )
uint32_t uiZ96, uiZ64;
bool sign;
uint64_t absA;
- uint_fast8_t shiftCount;
+ uint_fast8_t shiftDist;
uint32_t *ptr;
zWPtr = (uint32_t *) zPtr;
@@ -67,20 +67,20 @@ void i64_to_f128M( int64_t a, float128_t *zPtr )
if ( a ) {
sign = (a < 0);
absA = sign ? -(uint64_t) a : (uint64_t) a;
- shiftCount = softfloat_countLeadingZeros64( absA ) + 17;
- if ( shiftCount < 32 ) {
+ shiftDist = softfloat_countLeadingZeros64( absA ) + 17;
+ if ( shiftDist < 32 ) {
ptr = zWPtr + indexMultiwordHi( 4, 3 );
ptr[indexWord( 3, 2 )] = 0;
ptr[indexWord( 3, 1 )] = absA>>32;
ptr[indexWord( 3, 0 )] = absA;
- softfloat_shortShiftLeft96M( ptr, shiftCount, ptr );
+ softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
ptr[indexWordHi( 3 )] =
packToF128UI96(
- sign, 0x404E - shiftCount, ptr[indexWordHi( 3 )] );
+ sign, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
return;
}
- absA <<= shiftCount - 32;
- uiZ96 = packToF128UI96( sign, 0x404E - shiftCount, absA>>32 );
+ absA <<= shiftDist - 32;
+ uiZ96 = packToF128UI96( sign, 0x404E - shiftDist, absA>>32 );
uiZ64 = absA;
}
zWPtr[indexWord( 4, 3 )] = uiZ96;
diff --git a/source/i64_to_f16.c b/source/i64_to_f16.c
new file mode 100644
index 0000000..0543626
--- /dev/null
+++ b/source/i64_to_f16.c
@@ -0,0 +1,70 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t i64_to_f16( int64_t a )
+{
+ bool sign;
+ uint_fast64_t absA;
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ sign = (a < 0);
+ absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA ) - 53;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ sign, 0x18 - shiftDist, (uint_fast16_t) absA<<shiftDist )
+ : 0;
+ return u.f;
+ } else {
+ shiftDist += 4;
+ sig =
+ (shiftDist < 0)
+ ? softfloat_shortShiftRightJam64( absA, -shiftDist )
+ : (uint_fast16_t) absA<<shiftDist;
+ return softfloat_roundPackToF16( sign, 0x1C - shiftDist, sig );
+ }
+
+}
+
diff --git a/source/i64_to_f32.c b/source/i64_to_f32.c
index ae68ad9..e6d662d 100644
--- a/source/i64_to_f32.c
+++ b/source/i64_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,26 +44,26 @@ float32_t i64_to_f32( int64_t a )
{
bool sign;
uint_fast64_t absA;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui32_f32 u;
uint_fast32_t sig;
sign = (a < 0);
absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
- shiftCount = softfloat_countLeadingZeros64( absA ) - 40;
- if ( 0 <= shiftCount ) {
+ shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
+ if ( 0 <= shiftDist ) {
u.ui =
a ? packToF32UI(
- sign, 0x95 - shiftCount, (uint_fast32_t) absA<<shiftCount )
+ sign, 0x95 - shiftDist, (uint_fast32_t) absA<<shiftDist )
: 0;
return u.f;
} else {
- shiftCount += 7;
+ shiftDist += 7;
sig =
- (shiftCount < 0)
- ? softfloat_shortShiftRightJam64( absA, -shiftCount )
- : (uint_fast32_t) absA<<shiftCount;
- return softfloat_roundPackToF32( sign, 0x9C - shiftCount, sig );
+ (shiftDist < 0)
+ ? softfloat_shortShiftRightJam64( absA, -shiftDist )
+ : (uint_fast32_t) absA<<shiftDist;
+ return softfloat_roundPackToF32( sign, 0x9C - shiftDist, sig );
}
}
diff --git a/source/i64_to_f64.c b/source/i64_to_f64.c
index 952a049..e0f79a1 100644
--- a/source/i64_to_f64.c
+++ b/source/i64_to_f64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/include/internals.h b/source/include/internals.h
index cf57bdc..9045f6c 100644
--- a/source/include/internals.h
+++ b/source/include/internals.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,6 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "primitives.h"
#include "softfloat_types.h"
+union ui16_f16 { uint16_t ui; float16_t f; };
union ui32_f32 { uint32_t ui; float32_t f; };
union ui64_f64 { uint64_t ui; float64_t f; };
@@ -82,12 +83,33 @@ int_fast64_t softfloat_roundPackMToI64( bool, uint32_t *, uint_fast8_t, bool );
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
+#define signF16UI( a ) ((bool) ((uint16_t) (a)>>15))
+#define expF16UI( a ) ((int_fast8_t) ((a)>>10) & 0x1F)
+#define fracF16UI( a ) ((a) & 0x03FF)
+#define packToF16UI( sign, exp, sig ) (((uint16_t) (sign)<<15) + ((uint16_t) (exp)<<10) + (sig))
+
+#define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
+
+struct exp8_sig16 { int_fast8_t exp; uint_fast16_t sig; };
+struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t );
+
+float16_t softfloat_roundPackToF16( bool, int_fast16_t, uint_fast16_t );
+float16_t softfloat_normRoundPackToF16( bool, int_fast16_t, uint_fast16_t );
+
+float16_t softfloat_addMagsF16( uint_fast16_t, uint_fast16_t );
+float16_t softfloat_subMagsF16( uint_fast16_t, uint_fast16_t );
+float16_t
+ softfloat_mulAddF16(
+ uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
#define signF32UI( a ) ((bool) ((uint32_t) (a)>>31))
#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
#define fracF32UI( a ) ((a) & 0x007FFFFF)
#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
-#define isNaNF32UI( a ) ((((a) & 0x7F800000) == 0x7F800000) && ((a) & 0x007FFFFF))
+#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
@@ -95,8 +117,8 @@ struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
-float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t, bool );
-float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t, bool );
+float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
+float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
float32_t
softfloat_mulAddF32(
uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
@@ -108,7 +130,7 @@ float32_t
#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
-#define isNaNF64UI( a ) ((((a) & UINT64_C( 0x7FF0000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
+#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
@@ -159,7 +181,7 @@ extFloat80_t
#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
#define packToF128UI64( sign, exp, sig64 ) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<48) + (sig64))
-#define isNaNF128UI( a64, a0 ) ((((a64) & UINT64_C( 0x7FFF000000000000 )) == UINT64_C( 0x7FFF000000000000 )) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
+#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
struct exp32_sig128 { int_fast32_t exp; struct uint128 sig; };
struct exp32_sig128
diff --git a/source/include/primitiveTypes.h b/source/include/primitiveTypes.h
index 16aca67..4790a3c 100644
--- a/source/include/primitiveTypes.h
+++ b/source/include/primitiveTypes.h
@@ -2,7 +2,7 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/include/primitives.h b/source/include/primitives.h
index 9995556..279e5ea 100644
--- a/source/include/primitives.h
+++ b/source/include/primitives.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -43,61 +43,59 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shortShiftRightJam64
/*----------------------------------------------------------------------------
-| Shifts `a' right by the number of bits given in `count', which must be in
+| Shifts `a' right by the number of bits given in `dist', which must be in
| the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
| into the least-significant bit of the shifted value by setting the least-
| significant bit to 1. This shifted-and-jammed value is returned.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t count )
- { return a>>count | ((a & (((uint_fast64_t) 1<<count) - 1)) != 0); }
+uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
+ { return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
#else
-uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t count );
+uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist );
#endif
#endif
#ifndef softfloat_shiftRightJam32
/*----------------------------------------------------------------------------
-| Shifts `a' right by the number of bits given in `count', which must not
+| Shifts `a' right by the number of bits given in `dist', which must not
| be zero. If any nonzero bits are shifted off, they are "jammed" into the
| least-significant bit of the shifted value by setting the least-significant
| bit to 1. This shifted-and-jammed value is returned.
-| The value of `count' can be arbitrarily large. In particular, if `count'
-| is greater than 32, the result will be either 0 or 1, depending on whether
-| `a' is zero or nonzero.
+| The value of `dist' can be arbitrarily large. In particular, if `dist' is
+| greater than 32, the result will be either 0 or 1, depending on whether `a'
+| is zero or nonzero.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
-INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t count )
+INLINE uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
{
return
- (count < 31) ? a>>count | ((uint32_t) (a<<(-count & 31)) != 0)
- : (a != 0);
+ (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
}
#else
-uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t count );
+uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
#endif
#endif
#ifndef softfloat_shiftRightJam64
/*----------------------------------------------------------------------------
-| Shifts `a' right by the number of bits given in `count', which must not
+| Shifts `a' right by the number of bits given in `dist', which must not
| be zero. If any nonzero bits are shifted off, they are "jammed" into the
| least-significant bit of the shifted value by setting the least-significant
| bit to 1. This shifted-and-jammed value is returned.
-| The value of `count' can be arbitrarily large. In particular, if `count'
-| is greater than 64, the result will be either 0 or 1, depending on whether
-| `a' is zero or nonzero.
+| The value of `dist' can be arbitrarily large. In particular, if `dist' is
+| greater than 64, the result will be either 0 or 1, depending on whether `a'
+| is zero or nonzero.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
-INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t count )
+INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
{
return
- (count < 63) ? a>>count | ((uint64_t) (a<<(-count & 63)) != 0)
- : (a != 0);
+ (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
}
#else
-uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t count );
+uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
#endif
#endif
@@ -108,6 +106,27 @@ uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t count );
*----------------------------------------------------------------------------*/
extern const uint_least8_t softfloat_countLeadingZeros8[256];
+#ifndef softfloat_countLeadingZeros16
+/*----------------------------------------------------------------------------
+| Returns the number of leading 0 bits before the most-significant 1 bit of
+| `a'. If `a' is zero, 16 is returned.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
+{
+ uint_fast8_t count = 8;
+ if ( 0x100 <= a ) {
+ count = 0;
+ a >>= 8;
+ }
+ count += softfloat_countLeadingZeros8[a];
+ return count;
+}
+#else
+uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
+#endif
+#endif
+
#ifndef softfloat_countLeadingZeros32
/*----------------------------------------------------------------------------
| Returns the number of leading 0 bits before the most-significant 1 bit of
@@ -141,6 +160,9 @@ uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
#endif
+extern const uint16_t softfloat_approxRecip_1k0s[16];
+extern const uint16_t softfloat_approxRecip_1k1s[16];
+
#ifndef softfloat_approxRecip32_1
/*----------------------------------------------------------------------------
| Returns an approximation to the reciprocal of the number represented by `a',
@@ -160,6 +182,9 @@ uint32_t softfloat_approxRecip32_1( uint32_t a );
#endif
#endif
+extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
+extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
+
#ifndef softfloat_approxRecipSqrt32_1
/*----------------------------------------------------------------------------
| Returns an approximation to the reciprocal of the square root of the number
@@ -197,7 +222,7 @@ uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
INLINE
- bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
{ return (a64 == b64) && (a0 == b0); }
#else
bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
@@ -212,7 +237,7 @@ bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
{ return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
#else
bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
@@ -227,7 +252,7 @@ bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
{ return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
#else
bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
@@ -237,126 +262,126 @@ bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
#ifndef softfloat_shortShiftLeft128
/*----------------------------------------------------------------------------
| Shifts the 128 bits formed by concatenating `a64' and `a0' left by the
-| number of bits given in `count', which must be in the range 1 to 63.
+| number of bits given in `dist', which must be in the range 1 to 63.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- struct uint128
- softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t count )
+struct uint128
+ softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
{
struct uint128 z;
- z.v64 = a64<<count | a0>>(-count & 63);
- z.v0 = a0<<count;
+ z.v64 = a64<<dist | a0>>(-dist & 63);
+ z.v0 = a0<<dist;
return z;
}
#else
struct uint128
- softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t count );
+ softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
#endif
#endif
#ifndef softfloat_shortShiftRight128
/*----------------------------------------------------------------------------
| Shifts the 128 bits formed by concatenating `a64' and `a0' right by the
-| number of bits given in `count', which must be in the range 1 to 63.
+| number of bits given in `dist', which must be in the range 1 to 63.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- struct uint128
- softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t count )
+struct uint128
+ softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
{
struct uint128 z;
- z.v64 = a64>>count;
- z.v0 = a64<<(-count & 63) | a0>>count;
+ z.v64 = a64>>dist;
+ z.v0 = a64<<(-dist & 63) | a0>>dist;
return z;
}
#else
struct uint128
- softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t count );
+ softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
#endif
#endif
#ifndef softfloat_shortShiftRightJam64Extra
/*----------------------------------------------------------------------------
| This function is the same as `softfloat_shiftRightJam64Extra' (below),
-| except that `count' must be in the range 1 to 63.
+| except that `dist' must be in the range 1 to 63.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- struct uint64_extra
- softfloat_shortShiftRightJam64Extra(
- uint64_t a, uint64_t extra, uint_fast8_t count )
+struct uint64_extra
+ softfloat_shortShiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast8_t dist )
{
struct uint64_extra z;
- z.v = a>>count;
- z.extra = a<<(-count & 63) | (extra != 0);
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63) | (extra != 0);
return z;
}
#else
struct uint64_extra
softfloat_shortShiftRightJam64Extra(
- uint64_t a, uint64_t extra, uint_fast8_t count );
+ uint64_t a, uint64_t extra, uint_fast8_t dist );
#endif
#endif
#ifndef softfloat_shortShiftRightJam128
/*----------------------------------------------------------------------------
| Shifts the 128 bits formed by concatenating `a64' and `a0' right by the
-| number of bits given in `count', which must be in the range 1 to 63. If any
+| number of bits given in `dist', which must be in the range 1 to 63. If any
| nonzero bits are shifted off, they are "jammed" into the least-significant
| bit of the shifted value by setting the least-significant bit to 1. This
| shifted-and-jammed value is returned.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
INLINE
- struct uint128
- softfloat_shortShiftRightJam128(
- uint64_t a64, uint64_t a0, uint_fast8_t count )
+struct uint128
+ softfloat_shortShiftRightJam128(
+ uint64_t a64, uint64_t a0, uint_fast8_t dist )
{
- uint_fast8_t negCount = -count;
+ uint_fast8_t negDist = -dist;
struct uint128 z;
- z.v64 = a64>>count;
+ z.v64 = a64>>dist;
z.v0 =
- a64<<(negCount & 63) | a0>>count
- | ((uint64_t) (a0<<(negCount & 63)) != 0);
+ a64<<(negDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(negDist & 63)) != 0);
return z;
}
#else
struct uint128
softfloat_shortShiftRightJam128(
- uint64_t a64, uint64_t a0, uint_fast8_t count );
+ uint64_t a64, uint64_t a0, uint_fast8_t dist );
#endif
#endif
#ifndef softfloat_shortShiftRightJam128Extra
/*----------------------------------------------------------------------------
| This function is the same as `softfloat_shiftRightJam128Extra' (below),
-| except that `count' must be in the range 1 to 63.
+| except that `dist' must be in the range 1 to 63.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
INLINE
- struct uint128_extra
- softfloat_shortShiftRightJam128Extra(
- uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t count )
+struct uint128_extra
+ softfloat_shortShiftRightJam128Extra(
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
{
- uint_fast8_t negCount = -count;
+ uint_fast8_t negDist = -dist;
struct uint128_extra z;
- z.v.v64 = a64>>count;
- z.v.v0 = a64<<(negCount & 63) | a0>>count;
- z.extra = a0<<(negCount & 63) | (extra != 0);
+ z.v.v64 = a64>>dist;
+ z.v.v0 = a64<<(negDist & 63) | a0>>dist;
+ z.extra = a0<<(negDist & 63) | (extra != 0);
return z;
}
#else
struct uint128_extra
softfloat_shortShiftRightJam128Extra(
- uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t count );
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
#endif
#endif
#ifndef softfloat_shiftRightJam64Extra
/*----------------------------------------------------------------------------
| Shifts the 128 bits formed by concatenating `a' and `extra' right by 64
-| _plus_ the number of bits given in `count', which must not be zero. This
+| _plus_ the number of bits given in `dist', which must not be zero. This
| shifted value is at most 64 nonzero bits and is returned in the `v' field
| of the `struct uint64_extra' result. The 64-bit `extra' field of the result
| contains a value formed as follows from the bits that were shifted off: The
@@ -366,23 +391,23 @@ struct uint128_extra
| (This function makes more sense if `a' and `extra' are considered to form
| an unsigned fixed-point number with binary point between `a' and `extra'.
| This fixed-point value is shifted right by the number of bits given in
-| `count', and the integer part of this shifted value is returned in the `v'
+| `dist', and the integer part of this shifted value is returned in the `v'
| field of the result. The fractional part of the shifted value is modified
| as described above and returned in the `extra' field of the result.)
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
INLINE
- struct uint64_extra
- softfloat_shiftRightJam64Extra(
- uint64_t a, uint64_t extra, uint_fast32_t count )
+struct uint64_extra
+ softfloat_shiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast32_t dist )
{
struct uint64_extra z;
- if ( count < 64 ) {
- z.v = a>>count;
- z.extra = a<<(-count & 63);
+ if ( dist < 64 ) {
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63);
} else {
z.v = 0;
- z.extra = (count == 64) ? a : (a != 0);
+ z.extra = (dist == 64) ? a : (a != 0);
}
z.extra |= (extra != 0);
return z;
@@ -390,29 +415,29 @@ INLINE
#else
struct uint64_extra
softfloat_shiftRightJam64Extra(
- uint64_t a, uint64_t extra, uint_fast32_t count );
+ uint64_t a, uint64_t extra, uint_fast32_t dist );
#endif
#endif
#ifndef softfloat_shiftRightJam128
/*----------------------------------------------------------------------------
| Shifts the 128 bits formed by concatenating `a64' and `a0' right by the
-| number of bits given in `count', which must not be zero. If any nonzero
-| bits are shifted off, they are "jammed" into the least-significant bit of
-| the shifted value by setting the least-significant bit to 1. This shifted-
-| and-jammed value is returned.
-| The value of `count' can be arbitrarily large. In particular, if `count'
-| is greater than 128, the result will be either 0 or 1, depending on whether
-| the original 128 bits are all zeros.
+| number of bits given in `dist', which must not be zero. If any nonzero bits
+| are shifted off, they are "jammed" into the least-significant bit of the
+| shifted value by setting the least-significant bit to 1. This shifted-and-
+| jammed value is returned.
+| The value of `dist' can be arbitrarily large. In particular, if `dist' is
+| greater than 128, the result will be either 0 or 1, depending on whether the
+| original 128 bits are all zeros.
*----------------------------------------------------------------------------*/
struct uint128
- softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t count );
+ softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
#endif
#ifndef softfloat_shiftRightJam128Extra
/*----------------------------------------------------------------------------
| Shifts the 192 bits formed by concatenating `a64', `a0', and `extra' right
-| by 64 _plus_ the number of bits given in `count', which must not be zero.
+| by 64 _plus_ the number of bits given in `dist', which must not be zero.
| This shifted value is at most 128 nonzero bits and is returned in the `v'
| field of the `struct uint128_extra' result. The 64-bit `extra' field of the
| result contains a value formed as follows from the bits that were shifted
@@ -422,32 +447,32 @@ struct uint128
| (This function makes more sense if `a64', `a0', and `extra' are considered
| to form an unsigned fixed-point number with binary point between `a0' and
| `extra'. This fixed-point value is shifted right by the number of bits
-| given in `count', and the integer part of this shifted value is returned
+| given in `dist', and the integer part of this shifted value is returned
| in the `v' field of the result. The fractional part of the shifted value
| is modified as described above and returned in the `extra' field of the
| result.)
*----------------------------------------------------------------------------*/
struct uint128_extra
softfloat_shiftRightJam128Extra(
- uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t count );
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
#endif
#ifndef softfloat_shiftRightJam256M
/*----------------------------------------------------------------------------
| Shifts the 256-bit unsigned integer pointed to by `aPtr' right by the number
-| of bits given in `count', which must not be zero. If any nonzero bits are
+| of bits given in `dist', which must not be zero. If any nonzero bits are
| shifted off, they are "jammed" into the least-significant bit of the shifted
| value by setting the least-significant bit to 1. This shifted-and-jammed
| value is stored at the location pointed to by `zPtr'. Each of `aPtr' and
| `zPtr' points to an array of four 64-bit elements that concatenate in the
| platform's normal endian order to form a 256-bit integer.
-| The value of `count' can be arbitrarily large. In particular, if `count'
+| The value of `dist' can be arbitrarily large. In particular, if `dist'
| is greater than 256, the stored result will be either 0 or 1, depending on
| whether the original 256 bits are all zeros.
*----------------------------------------------------------------------------*/
void
softfloat_shiftRightJam256M(
- const uint64_t *aPtr, uint_fast32_t count, uint64_t *zPtr );
+ const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
#endif
#ifndef softfloat_add128
@@ -458,8 +483,8 @@ void
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- struct uint128
- softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+struct uint128
+ softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
{
struct uint128 z;
z.v0 = a0 + b0;
@@ -493,8 +518,8 @@ void
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- struct uint128
- softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+struct uint128
+ softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
{
struct uint128 z;
z.v0 = a0 - b0;
@@ -556,7 +581,7 @@ struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
INLINE
- struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
+struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
{
struct uint128 z;
uint_fast64_t mid;
@@ -620,33 +645,33 @@ int_fast8_t
#ifndef softfloat_shortShiftLeft64To96M
/*----------------------------------------------------------------------------
| Extends `a' to 96 bits and shifts the value left by the number of bits given
-| in `count', which must be in the range 1 to 31. The result is stored at the
+| in `dist', which must be in the range 1 to 31. The result is stored at the
| location pointed to by `zPtr'. Argument `zPtr' points to an array of three
| 32-bit elements that concatenate in the platform's normal endian order to
| form a 96-bit integer.
*----------------------------------------------------------------------------*/
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
INLINE
- void
- softfloat_shortShiftLeft64To96M(
- uint64_t a, uint_fast8_t count, uint32_t *zPtr )
+void
+ softfloat_shortShiftLeft64To96M(
+ uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
{
- zPtr[indexWord( 3, 0 )] = (uint32_t) a<<count;
- a >>= 32 - count;
+ zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
+ a >>= 32 - dist;
zPtr[indexWord( 3, 2 )] = a>>32;
zPtr[indexWord( 3, 1 )] = a;
}
#else
void
softfloat_shortShiftLeft64To96M(
- uint64_t a, uint_fast8_t count, uint32_t *zPtr );
+ uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
#endif
#endif
#ifndef softfloat_shortShiftLeftM
/*----------------------------------------------------------------------------
| Shifts the N-bit unsigned integer pointed to by `aPtr' left by the number
-| of bits given in `count', where N = `size_words' * 32. The value of `count'
+| of bits given in `dist', where N = `size_words' * 32. The value of `dist'
| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
| shifted N-bit result is stored at the location pointed to by `zPtr'. Each
| of `aPtr' and `zPtr' points to a `size_words'-long array of 32-bit elements
@@ -657,7 +682,7 @@ void
softfloat_shortShiftLeftM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint32_t *zPtr
);
#endif
@@ -667,7 +692,7 @@ void
| This function or macro is the same as `softfloat_shortShiftLeftM' with
| `size_words' = 3 (N = 96).
*----------------------------------------------------------------------------*/
-#define softfloat_shortShiftLeft96M( aPtr, count, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, count, zPtr )
+#define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shortShiftLeft128M
@@ -675,7 +700,7 @@ void
| This function or macro is the same as `softfloat_shortShiftLeftM' with
| `size_words' = 4 (N = 128).
*----------------------------------------------------------------------------*/
-#define softfloat_shortShiftLeft128M( aPtr, count, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, count, zPtr )
+#define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shortShiftLeft160M
@@ -683,25 +708,25 @@ void
| This function or macro is the same as `softfloat_shortShiftLeftM' with
| `size_words' = 5 (N = 160).
*----------------------------------------------------------------------------*/
-#define softfloat_shortShiftLeft160M( aPtr, count, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, count, zPtr )
+#define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftLeftM
/*----------------------------------------------------------------------------
| Shifts the N-bit unsigned integer pointed to by `aPtr' left by the number
-| of bits given in `count', where N = `size_words' * 32. The value of `count'
+| of bits given in `dist', where N = `size_words' * 32. The value of `dist'
| must not be zero. Any nonzero bits shifted off are lost. The shifted
| N-bit result is stored at the location pointed to by `zPtr'. Each of `aPtr'
| and `zPtr' points to a `size_words'-long array of 32-bit elements that
| concatenate in the platform's normal endian order to form an N-bit integer.
-| The value of `count' can be arbitrarily large. In particular, if `count'
-| is greater than N, the stored result will be 0.
+| The value of `dist' can be arbitrarily large. In particular, if `dist' is
+| greater than N, the stored result will be 0.
*----------------------------------------------------------------------------*/
void
softfloat_shiftLeftM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint32_t count,
+ uint32_t dist,
uint32_t *zPtr
);
#endif
@@ -711,7 +736,7 @@ void
| This function or macro is the same as `softfloat_shiftLeftM' with
| `size_words' = 3 (N = 96).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftLeft96M( aPtr, count, zPtr ) softfloat_shiftLeftM( 3, aPtr, count, zPtr )
+#define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftLeft128M
@@ -719,7 +744,7 @@ void
| This function or macro is the same as `softfloat_shiftLeftM' with
| `size_words' = 4 (N = 128).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftLeft128M( aPtr, count, zPtr ) softfloat_shiftLeftM( 4, aPtr, count, zPtr )
+#define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftLeft160M
@@ -727,13 +752,13 @@ void
| This function or macro is the same as `softfloat_shiftLeftM' with
| `size_words' = 5 (N = 160).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftLeft160M( aPtr, count, zPtr ) softfloat_shiftLeftM( 5, aPtr, count, zPtr )
+#define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shortShiftRightM
/*----------------------------------------------------------------------------
| Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number
-| of bits given in `count', where N = `size_words' * 32. The value of `count'
+| of bits given in `dist', where N = `size_words' * 32. The value of `dist'
| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
| shifted N-bit result is stored at the location pointed to by `zPtr'. Each
| of `aPtr' and `zPtr' points to a `size_words'-long array of 32-bit elements
@@ -744,7 +769,7 @@ void
softfloat_shortShiftRightM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint32_t *zPtr
);
#endif
@@ -754,7 +779,7 @@ void
| This function or macro is the same as `softfloat_shortShiftRightM' with
| `size_words' = 4 (N = 128).
*----------------------------------------------------------------------------*/
-#define softfloat_shortShiftRight128M( aPtr, count, zPtr ) softfloat_shortShiftRightM( 4, aPtr, count, zPtr )
+#define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shortShiftRight160M
@@ -762,13 +787,13 @@ void
| This function or macro is the same as `softfloat_shortShiftRightM' with
| `size_words' = 5 (N = 160).
*----------------------------------------------------------------------------*/
-#define softfloat_shortShiftRight160M( aPtr, count, zPtr ) softfloat_shortShiftRightM( 5, aPtr, count, zPtr )
+#define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shortShiftRightJamM
/*----------------------------------------------------------------------------
| Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number
-| of bits given in `count', where N = `size_words' * 32. The value of `count'
+| of bits given in `dist', where N = `size_words' * 32. The value of `dist'
| must be in the range 1 to 31. If any nonzero bits are shifted off, they are
| "jammed" into the least-significant bit of the shifted value by setting the
| least-significant bit to 1. This shifted-and-jammed N-bit result is stored
@@ -786,25 +811,25 @@ void
| This function or macro is the same as `softfloat_shortShiftRightJamM' with
| `size_words' = 5 (N = 160).
*----------------------------------------------------------------------------*/
-#define softfloat_shortShiftRightJam160M( aPtr, count, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, count, zPtr )
+#define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftRightM
/*----------------------------------------------------------------------------
| Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number
-| of bits given in `count', where N = `size_words' * 32. The value of `count'
+| of bits given in `dist', where N = `size_words' * 32. The value of `dist'
| must not be zero. Any nonzero bits shifted off are lost. The shifted
| N-bit result is stored at the location pointed to by `zPtr'. Each of `aPtr'
| and `zPtr' points to a `size_words'-long array of 32-bit elements that
| concatenate in the platform's normal endian order to form an N-bit integer.
-| The value of `count' can be arbitrarily large. In particular, if `count'
-| is greater than N, the stored result will be 0.
+| The value of `dist' can be arbitrarily large. In particular, if `dist' is
+| greater than N, the stored result will be 0.
*----------------------------------------------------------------------------*/
void
softfloat_shiftRightM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint32_t count,
+ uint32_t dist,
uint32_t *zPtr
);
#endif
@@ -814,20 +839,20 @@ void
| This function or macro is the same as `softfloat_shiftRightM' with
| `size_words' = 3 (N = 96).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftRight96M( aPtr, count, zPtr ) softfloat_shiftRightM( 3, aPtr, count, zPtr )
+#define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftRightJamM
/*----------------------------------------------------------------------------
| Shifts the N-bit unsigned integer pointed to by `aPtr' right by the number
-| of bits given in `count', where N = `size_words' * 32. The value of `count'
+| of bits given in `dist', where N = `size_words' * 32. The value of `dist'
| must not be zero. If any nonzero bits are shifted off, they are "jammed"
| into the least-significant bit of the shifted value by setting the least-
| significant bit to 1. This shifted-and-jammed N-bit result is stored
| at the location pointed to by `zPtr'. Each of `aPtr' and `zPtr' points
| to a `size_words'-long array of 32-bit elements that concatenate in the
| platform's normal endian order to form an N-bit integer.
-| The value of `count' can be arbitrarily large. In particular, if `count'
+| The value of `dist' can be arbitrarily large. In particular, if `dist'
| is greater than N, the stored result will be either 0 or 1, depending on
| whether the original N bits are all zeros.
*----------------------------------------------------------------------------*/
@@ -835,7 +860,7 @@ void
softfloat_shiftRightJamM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint32_t count,
+ uint32_t dist,
uint32_t *zPtr
);
#endif
@@ -845,7 +870,7 @@ void
| This function or macro is the same as `softfloat_shiftRightJamM' with
| `size_words' = 3 (N = 96).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftRightJam96M( aPtr, count, zPtr ) softfloat_shiftRightJamM( 3, aPtr, count, zPtr )
+#define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftRightJam128M
@@ -853,7 +878,7 @@ void
| This function or macro is the same as `softfloat_shiftRightJamM' with
| `size_words' = 4 (N = 128).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftRightJam128M( aPtr, count, zPtr ) softfloat_shiftRightJamM( 4, aPtr, count, zPtr )
+#define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
#endif
#ifndef softfloat_shiftRightJam160M
@@ -861,7 +886,7 @@ void
| This function or macro is the same as `softfloat_shiftRightJamM' with
| `size_words' = 5 (N = 160).
*----------------------------------------------------------------------------*/
-#define softfloat_shiftRightJam160M( aPtr, count, zPtr ) softfloat_shiftRightJamM( 5, aPtr, count, zPtr )
+#define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
#endif
#ifndef softfloat_addM
@@ -1088,7 +1113,7 @@ void
/*----------------------------------------------------------------------------
| Performs a "remainder reduction step" as follows: Arguments `remPtr' and
| `bPtr' both point to N-bit unsigned integers, where N = `size_words' * 32.
-| Defining R and B as the values of those integers, the expression (R<<`count')
+| Defining R and B as the values of those integers, the expression (R<<`dist')
| - B * q is computed modulo 2^N, and the N-bit result is stored at the
| location pointed to by `zPtr'. Each of `remPtr', `bPtr', and `zPtr' points
| to a `size_words'-long array of 32-bit elements that concatenate in the
@@ -1098,7 +1123,7 @@ void
softfloat_remStepMBy32(
uint_fast8_t size_words,
const uint32_t *remPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
const uint32_t *bPtr,
uint32_t q,
uint32_t *zPtr
@@ -1110,7 +1135,7 @@ void
| This function or macro is the same as `softfloat_remStepMBy32' with
| `size_words' = 3 (N = 96).
*----------------------------------------------------------------------------*/
-#define softfloat_remStep96MBy32( remPtr, count, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, count, bPtr, q, zPtr )
+#define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
#endif
#ifndef softfloat_remStep128MBy32
@@ -1118,7 +1143,7 @@ void
| This function or macro is the same as `softfloat_remStepMBy32' with
| `size_words' = 4 (N = 128).
*----------------------------------------------------------------------------*/
-#define softfloat_remStep128MBy32( remPtr, count, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, count, bPtr, q, zPtr )
+#define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
#endif
#ifndef softfloat_remStep160MBy32
@@ -1126,7 +1151,7 @@ void
| This function or macro is the same as `softfloat_remStepMBy32' with
| `size_words' = 5 (N = 160).
*----------------------------------------------------------------------------*/
-#define softfloat_remStep160MBy32( remPtr, count, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, count, bPtr, q, zPtr )
+#define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
#endif
#endif
diff --git a/source/include/softfloat.h b/source/include/softfloat.h
index 3f424fc..8f82288 100644
--- a/source/include/softfloat.h
+++ b/source/include/softfloat.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -48,13 +48,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <stdint.h>
-
#include "softfloat_types.h"
+#ifndef THREAD_LOCAL
+#define THREAD_LOCAL
+#endif
+
/*----------------------------------------------------------------------------
| Software floating-point underflow tininess-detection mode.
*----------------------------------------------------------------------------*/
-extern uint_fast8_t softfloat_detectTininess;
+extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
enum {
softfloat_tininess_beforeRounding = 0,
softfloat_tininess_afterRounding = 1
@@ -63,7 +66,7 @@ enum {
/*----------------------------------------------------------------------------
| Software floating-point rounding mode.
*----------------------------------------------------------------------------*/
-extern uint_fast8_t softfloat_roundingMode;
+extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
enum {
softfloat_round_near_even = 0,
softfloat_round_minMag = 1,
@@ -75,7 +78,7 @@ enum {
/*----------------------------------------------------------------------------
| Software floating-point exception flags.
*----------------------------------------------------------------------------*/
-extern uint_fast8_t softfloat_exceptionFlags;
+extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
enum {
softfloat_flag_inexact = 1,
softfloat_flag_underflow = 2,
@@ -92,6 +95,7 @@ void softfloat_raiseFlags( uint_fast8_t );
/*----------------------------------------------------------------------------
| Integer-to-floating-point conversion routines.
*----------------------------------------------------------------------------*/
+float16_t ui32_to_f16( uint32_t );
float32_t ui32_to_f32( uint32_t );
float64_t ui32_to_f64( uint32_t );
#ifdef SOFTFLOAT_FAST_INT64
@@ -100,6 +104,7 @@ float128_t ui32_to_f128( uint32_t );
#endif
void ui32_to_extF80M( uint32_t, extFloat80_t * );
void ui32_to_f128M( uint32_t, float128_t * );
+float16_t ui64_to_f16( uint64_t );
float32_t ui64_to_f32( uint64_t );
float64_t ui64_to_f64( uint64_t );
#ifdef SOFTFLOAT_FAST_INT64
@@ -108,6 +113,7 @@ float128_t ui64_to_f128( uint64_t );
#endif
void ui64_to_extF80M( uint64_t, extFloat80_t * );
void ui64_to_f128M( uint64_t, float128_t * );
+float16_t i32_to_f16( int32_t );
float32_t i32_to_f32( int32_t );
float64_t i32_to_f64( int32_t );
#ifdef SOFTFLOAT_FAST_INT64
@@ -116,6 +122,7 @@ float128_t i32_to_f128( int32_t );
#endif
void i32_to_extF80M( int32_t, extFloat80_t * );
void i32_to_f128M( int32_t, float128_t * );
+float16_t i64_to_f16( int64_t );
float32_t i64_to_f32( int64_t );
float64_t i64_to_f64( int64_t );
#ifdef SOFTFLOAT_FAST_INT64
@@ -126,6 +133,41 @@ void i64_to_extF80M( int64_t, extFloat80_t * );
void i64_to_f128M( int64_t, float128_t * );
/*----------------------------------------------------------------------------
+| 16-bit (half-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
+uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
+int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
+int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
+uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
+uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
+int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
+int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
+float32_t f16_to_f32( float16_t );
+float64_t f16_to_f64( float16_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t f16_to_extF80( float16_t );
+float128_t f16_to_f128( float16_t );
+#endif
+void f16_to_extF80M( float16_t, extFloat80_t * );
+void f16_to_f128M( float16_t, float128_t * );
+float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
+float16_t f16_add( float16_t, float16_t );
+float16_t f16_sub( float16_t, float16_t );
+float16_t f16_mul( float16_t, float16_t );
+float16_t f16_mulAdd( float16_t, float16_t, float16_t );
+float16_t f16_div( float16_t, float16_t );
+float16_t f16_rem( float16_t, float16_t );
+float16_t f16_sqrt( float16_t );
+bool f16_eq( float16_t, float16_t );
+bool f16_le( float16_t, float16_t );
+bool f16_lt( float16_t, float16_t );
+bool f16_eq_signaling( float16_t, float16_t );
+bool f16_le_quiet( float16_t, float16_t );
+bool f16_lt_quiet( float16_t, float16_t );
+bool f16_isSignalingNaN( float16_t );
+
+/*----------------------------------------------------------------------------
| 32-bit (single-precision) floating-point operations.
*----------------------------------------------------------------------------*/
uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
@@ -136,6 +178,7 @@ uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
+float16_t f32_to_f16( float32_t );
float64_t f32_to_f64( float32_t );
#ifdef SOFTFLOAT_FAST_INT64
extFloat80_t f32_to_extF80( float32_t );
@@ -170,6 +213,7 @@ uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
+float16_t f64_to_f16( float64_t );
float32_t f64_to_f32( float64_t );
#ifdef SOFTFLOAT_FAST_INT64
extFloat80_t f64_to_extF80( float64_t );
@@ -197,7 +241,7 @@ bool f64_isSignalingNaN( float64_t );
| Rounding precision for 80-bit extended double-precision floating-point.
| Valid values are 32, 64, and 80.
*----------------------------------------------------------------------------*/
-extern uint_fast8_t extF80_roundingPrecision;
+extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
/*----------------------------------------------------------------------------
| 80-bit extended double-precision floating-point operations.
@@ -211,6 +255,7 @@ uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
+float16_t extF80_to_f16( extFloat80_t );
float32_t extF80_to_f32( extFloat80_t );
float64_t extF80_to_f64( extFloat80_t );
float128_t extF80_to_f128( extFloat80_t );
@@ -237,6 +282,7 @@ uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
+float16_t extF80M_to_f16( const extFloat80_t * );
float32_t extF80M_to_f32( const extFloat80_t * );
float64_t extF80M_to_f64( const extFloat80_t * );
void extF80M_to_f128M( const extFloat80_t *, float128_t * );
@@ -269,6 +315,7 @@ uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
+float16_t f128_to_f16( float128_t );
float32_t f128_to_f32( float128_t );
float64_t f128_to_f64( float128_t );
extFloat80_t f128_to_extF80( float128_t );
@@ -296,6 +343,7 @@ uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
+float16_t f128M_to_f16( const float128_t * );
float32_t f128M_to_f32( const float128_t * );
float64_t f128M_to_f64( const float128_t * );
void f128M_to_extF80M( const float128_t *, extFloat80_t * );
diff --git a/source/include/softfloat_types.h b/source/include/softfloat_types.h
index c7b67ae..e882515 100644
--- a/source/include/softfloat_types.h
+++ b/source/include/softfloat_types.h
@@ -2,10 +2,10 @@
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,13 +40,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdint.h>
/*----------------------------------------------------------------------------
-| Types used to pass 32-bit, 64-bit, and 128-bit floating-point arguments and
-| results to/from functions. These types must be exactly 32 bits, 64 bits,
-| and 128 bits in size, respectively. Where a platform has "native" support
-| for IEEE-Standard floating-point formats, the types below may, if desired,
-| be defined as aliases for the native types (typically `float' and `double',
-| and possibly `long double').
+| Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
+| arguments and results to/from functions. These types must be exactly
+| 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
+| platform has "native" support for IEEE-Standard floating-point formats,
+| the types below may, if desired, be defined as aliases for the native types
+| (typically `float' and `double', and possibly `long double').
*----------------------------------------------------------------------------*/
+typedef struct { uint16_t v; } float16_t;
typedef struct { uint32_t v; } float32_t;
typedef struct { uint64_t v; } float64_t;
typedef struct { uint64_t v[2]; } float128_t;
diff --git a/source/s_add128.c b/source/s_add128.c
index cabbb73..a8e3e47 100644
--- a/source/s_add128.c
+++ b/source/s_add128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_add256M.c b/source/s_add256M.c
index 226be60..8328e70 100644
--- a/source/s_add256M.c
+++ b/source/s_add256M.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -55,7 +55,7 @@ void
wordZ = wordA + bPtr[index] + carry;
zPtr[index] = wordZ;
if ( index == indexWordHi( 4 ) ) break;
- carry = carry ? (wordZ <= wordA) : (wordZ < wordA);
+ if ( wordZ != wordA ) carry = (wordZ < wordA);
index += wordIncr;
}
diff --git a/source/s_addCarryM.c b/source/s_addCarryM.c
index 0f3c997..d798c93 100644
--- a/source/s_addCarryM.c
+++ b/source/s_addCarryM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@ uint_fast8_t
wordA = aPtr[index];
wordZ = wordA + bPtr[index] + carry;
zPtr[index] = wordZ;
- carry = carry ? (wordZ <= wordA) : (wordZ < wordA);
+ if ( wordZ != wordA ) carry = (wordZ < wordA);
if ( index == lastIndex ) break;
index += wordIncr;
}
diff --git a/source/s_addComplCarryM.c b/source/s_addComplCarryM.c
index 6f22273..5a342c6 100644
--- a/source/s_addComplCarryM.c
+++ b/source/s_addComplCarryM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@ uint_fast8_t
wordA = aPtr[index];
wordZ = wordA + ~bPtr[index] + carry;
zPtr[index] = wordZ;
- carry = carry ? (wordZ <= wordA) : (wordZ < wordA);
+ if ( wordZ != wordA ) carry = (wordZ < wordA);
if ( index == lastIndex ) break;
index += wordIncr;
}
diff --git a/source/s_addExtF80M.c b/source/s_addExtF80M.c
index f5218fa..7abdcd2 100644
--- a/source/s_addExtF80M.c
+++ b/source/s_addExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_addF128M.c b/source/s_addF128M.c
index 97cd7ba..4d6b299 100644
--- a/source/s_addF128M.c
+++ b/source/s_addF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_addM.c b/source/s_addM.c
index f01be48..66a2ccf 100644
--- a/source/s_addM.c
+++ b/source/s_addM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -60,7 +60,7 @@ void
wordZ = wordA + bPtr[index] + carry;
zPtr[index] = wordZ;
if ( index == lastIndex ) break;
- carry = carry ? (wordZ <= wordA) : (wordZ < wordA);
+ if ( wordZ != wordA ) carry = (wordZ < wordA);
index += wordIncr;
}
diff --git a/source/s_addMagsExtF80.c b/source/s_addMagsExtF80.c
index d6ccb0d..b0a0ccb 100644
--- a/source/s_addMagsExtF80.c
+++ b/source/s_addMagsExtF80.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_addMagsF128.c b/source/s_addMagsF128.c
index babfbec..0d8b36a 100644
--- a/source/s_addMagsF128.c
+++ b/source/s_addMagsF128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_addMagsF16.c b/source/s_addMagsF16.c
new file mode 100644
index 0000000..43ae655
--- /dev/null
+++ b/source/s_addMagsF16.c
@@ -0,0 +1,178 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t softfloat_addMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ int_fast8_t expDiff;
+ uint_fast16_t uiZ;
+ bool signZ;
+ int_fast8_t expZ;
+ uint_fast16_t sigZ;
+ uint_fast16_t sigX, sigY;
+ int_fast8_t shiftDist;
+ uint_fast32_t sig32Z;
+ int_fast8_t roundingMode;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
+ if ( expA == 0x1F ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ signZ = signF16UI( uiA );
+ expZ = expA;
+ sigZ = 0x0800 + sigA + sigB;
+ if ( ! (sigZ & 1) && (expZ < 0x1E) ) {
+ sigZ >>= 1;
+ goto pack;
+ }
+ sigZ <<= 3;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF16UI( uiA );
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ goto uiZ;
+ }
+ if ( expDiff <= -13 ) {
+ uiZ = packToF16UI( signZ, expB, sigB );
+ if ( expA | sigA ) goto addEpsilon;
+ goto uiZ;
+ }
+ expZ = expB;
+ sigX = sigB | 0x0400;
+ sigY = sigA + (expA ? 0x0400 : sigA);
+ shiftDist = 19 + expDiff;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ uiZ = uiA;
+ if ( expA == 0x1F ) {
+ if ( sigA ) goto propagateNaN;
+ goto uiZ;
+ }
+ if ( 13 <= expDiff ) {
+ if ( expB | sigB ) goto addEpsilon;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigX = sigA | 0x0400;
+ sigY = sigB + (expB ? 0x0400 : sigB);
+ shiftDist = 19 - expDiff;
+ }
+ sig32Z =
+ ((uint_fast32_t) sigX<<19) + ((uint_fast32_t) sigY<<shiftDist);
+ if ( sig32Z < 0x40000000 ) {
+ --expZ;
+ sig32Z <<= 1;
+ }
+ sigZ = sig32Z>>16;
+ if ( sig32Z & 0xFFFF ) {
+ sigZ |= 1;
+ } else {
+ if ( ! (sigZ & 0xF) && (expZ < 0x1E) ) {
+ sigZ >>= 4;
+ goto pack;
+ }
+ }
+ }
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ addEpsilon:
+ roundingMode = softfloat_roundingMode;
+ if ( roundingMode != softfloat_round_near_even ) {
+ if (
+ roundingMode
+ == (signF16UI( uiZ ) ? softfloat_round_min
+ : softfloat_round_max)
+ ) {
+ ++uiZ;
+ if ( (uint16_t) (uiZ<<1) == 0xF800 ) {
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ }
+ }
+ }
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ pack:
+ uiZ = packToF16UI( signZ, expZ, sigZ );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/s_addMagsF32.c b/source/s_addMagsF32.c
index c1b6b2d..01a1877 100644
--- a/source/s_addMagsF32.c
+++ b/source/s_addMagsF32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,8 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "internals.h"
#include "specialize.h"
-float32_t
- softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB, bool signZ )
+float32_t softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
{
int_fast16_t expA;
uint_fast32_t sigA;
@@ -49,30 +48,46 @@ float32_t
uint_fast32_t sigB;
int_fast16_t expDiff;
uint_fast32_t uiZ;
+ bool signZ;
int_fast16_t expZ;
uint_fast32_t sigZ;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expA = expF32UI( uiA );
sigA = fracF32UI( uiA );
expB = expF32UI( uiB );
sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expDiff = expA - expB;
- sigA <<= 6;
- sigB <<= 6;
if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
if ( expA == 0xFF ) {
if ( sigA | sigB ) goto propagateNaN;
uiZ = uiA;
goto uiZ;
}
- if ( ! expA ) {
- uiZ = packToF32UI( signZ, 0, (uiA + uiB) & 0x7FFFFFFF );
+ signZ = signF32UI( uiA );
+ expZ = expA;
+ sigZ = 0x01000000 + sigA + sigB;
+ if ( ! (sigZ & 1) && (expZ < 0xFE) ) {
+ uiZ = packToF32UI( signZ, expZ, sigZ>>1 );
goto uiZ;
}
- expZ = expA;
- sigZ = 0x40000000 + sigA + sigB;
+ sigZ <<= 6;
} else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF32UI( uiA );
+ sigA <<= 6;
+ sigB <<= 6;
if ( expDiff < 0 ) {
if ( expB == 0xFF ) {
if ( sigB ) goto propagateNaN;
@@ -99,6 +114,8 @@ float32_t
}
}
return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
propagateNaN:
uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
uiZ:
diff --git a/source/s_addMagsF64.c b/source/s_addMagsF64.c
index ba67e7c..72c1dd0 100644
--- a/source/s_addMagsF64.c
+++ b/source/s_addMagsF64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -53,28 +53,35 @@ float64_t
uint_fast64_t sigZ;
union ui64_f64 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expA = expF64UI( uiA );
sigA = fracF64UI( uiA );
expB = expF64UI( uiB );
sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expDiff = expA - expB;
- sigA <<= 9;
- sigB <<= 9;
if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
if ( expA == 0x7FF ) {
if ( sigA | sigB ) goto propagateNaN;
uiZ = uiA;
goto uiZ;
}
- if ( ! expA ) {
- uiZ =
- packToF64UI(
- signZ, 0, (uiA + uiB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) );
- goto uiZ;
- }
expZ = expA;
- sigZ = UINT64_C( 0x4000000000000000 ) + sigA + sigB;
+ sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
+ sigZ <<= 9;
} else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sigA <<= 9;
+ sigB <<= 9;
if ( expDiff < 0 ) {
if ( expB == 0x7FF ) {
if ( sigB ) goto propagateNaN;
@@ -82,7 +89,11 @@ float64_t
goto uiZ;
}
expZ = expB;
- sigA += expA ? UINT64_C( 0x2000000000000000 ) : sigA;
+ if ( expA ) {
+ sigA += UINT64_C( 0x2000000000000000 );
+ } else {
+ sigA <<= 1;
+ }
sigA = softfloat_shiftRightJam64( sigA, -expDiff );
} else {
if ( expA == 0x7FF ) {
@@ -91,7 +102,11 @@ float64_t
goto uiZ;
}
expZ = expA;
- sigB += expB ? UINT64_C( 0x2000000000000000 ) : sigB;
+ if ( expB ) {
+ sigB += UINT64_C( 0x2000000000000000 );
+ } else {
+ sigB <<= 1;
+ }
sigB = softfloat_shiftRightJam64( sigB, expDiff );
}
sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
@@ -101,6 +116,8 @@ float64_t
}
}
return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
propagateNaN:
uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
uiZ:
diff --git a/source/s_approxRecip32_1.c b/source/s_approxRecip32_1.c
index 14ddd95..e3ecb46 100644
--- a/source/s_approxRecip32_1.c
+++ b/source/s_approxRecip32_1.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,30 +39,25 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_approxRecip32_1
+extern const uint16_t softfloat_approxRecip_1k0s[16];
+extern const uint16_t softfloat_approxRecip_1k1s[16];
+
uint32_t softfloat_approxRecip32_1( uint32_t a )
{
int index;
- uint16_t eps;
- static const uint16_t k0s[] = {
- 0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
- 0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
- };
- static const uint16_t k1s[] = {
- 0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
- 0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
- };
- uint16_t r0;
- uint32_t delta0;
+ uint16_t eps, r0;
+ uint32_t sigma0;
uint_fast32_t r;
- uint32_t sqrDelta0;
+ uint32_t sqrSigma0;
index = a>>27 & 0xF;
eps = (uint16_t) (a>>11);
- r0 = k0s[index] - ((k1s[index] * (uint_fast32_t) eps)>>20);
- delta0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
- r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) delta0)>>24);
- sqrDelta0 = ((uint_fast64_t) delta0 * delta0)>>32;
- r += ((uint32_t) r * (uint_fast64_t) sqrDelta0)>>48;
+ r0 = softfloat_approxRecip_1k0s[index]
+ - ((softfloat_approxRecip_1k1s[index] * (uint_fast32_t) eps)>>20);
+ sigma0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
+ r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>24);
+ sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
+ r += ((uint32_t) r * (uint_fast64_t) sqrSigma0)>>48;
return r;
}
diff --git a/source/s_approxRecipSqrt32_1.c b/source/s_approxRecipSqrt32_1.c
index a318673..86598d6 100644
--- a/source/s_approxRecipSqrt32_1.c
+++ b/source/s_approxRecipSqrt32_1.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,34 +39,30 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_approxRecipSqrt32_1
+extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
+extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
+
uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a )
{
int index;
- uint16_t eps;
- static const uint16_t k0s[] = {
- 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
- 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
- };
- static const uint16_t k1s[] = {
- 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
- 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
- };
- uint16_t r0;
+ uint16_t eps, r0;
uint_fast32_t ESqrR0;
- uint32_t delta0;
+ uint32_t sigma0;
uint_fast32_t r;
- uint32_t sqrDelta0;
+ uint32_t sqrSigma0;
index = (a>>27 & 0xE) + oddExpA;
eps = (uint16_t) (a>>12);
- r0 = k0s[index] - ((k1s[index] * (uint_fast32_t) eps)>>20);
+ r0 = softfloat_approxRecipSqrt_1k0s[index]
+ - ((softfloat_approxRecipSqrt_1k1s[index] * (uint_fast32_t) eps)
+ >>20);
ESqrR0 = (uint_fast32_t) r0 * r0;
if ( ! oddExpA ) ESqrR0 <<= 1;
- delta0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
- r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) delta0)>>25);
- sqrDelta0 = ((uint_fast64_t) delta0 * delta0)>>32;
+ sigma0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
+ r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>25);
+ sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
r += ((uint32_t) ((r>>1) + (r>>3) - ((uint_fast32_t) r0<<14))
- * (uint_fast64_t) sqrDelta0)
+ * (uint_fast64_t) sqrSigma0)
>>48;
if ( ! (r & 0x80000000) ) r = 0x80000000;
return r;
diff --git a/source/s_approxRecipSqrt_1Ks.c b/source/s_approxRecipSqrt_1Ks.c
new file mode 100644
index 0000000..b6b5de9
--- /dev/null
+++ b/source/s_approxRecipSqrt_1Ks.c
@@ -0,0 +1,49 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "primitives.h"
+
+const uint16_t softfloat_approxRecipSqrt_1k0s[16] = {
+ 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
+ 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
+};
+const uint16_t softfloat_approxRecipSqrt_1k1s[16] = {
+ 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
+ 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
+};
+
diff --git a/source/s_approxRecip_1Ks.c b/source/s_approxRecip_1Ks.c
new file mode 100644
index 0000000..52d41f1
--- /dev/null
+++ b/source/s_approxRecip_1Ks.c
@@ -0,0 +1,49 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "primitives.h"
+
+const uint16_t softfloat_approxRecip_1k0s[16] = {
+ 0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
+ 0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
+};
+const uint16_t softfloat_approxRecip_1k1s[16] = {
+ 0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
+ 0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
+};
+
diff --git a/source/s_compare128M.c b/source/s_compare128M.c
index 005f58c..f61706d 100644
--- a/source/s_compare128M.c
+++ b/source/s_compare128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_compare96M.c b/source/s_compare96M.c
index 5ec6965..3928fb1 100644
--- a/source/s_compare96M.c
+++ b/source/s_compare96M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_compareNonnormExtF80M.c b/source/s_compareNonnormExtF80M.c
index 986fbb2..c528024 100644
--- a/source/s_compareNonnormExtF80M.c
+++ b/source/s_compareNonnormExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_countLeadingZeros16.c b/source/s_countLeadingZeros16.c
new file mode 100644
index 0000000..5ae3f74
--- /dev/null
+++ b/source/s_countLeadingZeros16.c
@@ -0,0 +1,60 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+
+#ifndef softfloat_countLeadingZeros16
+
+#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
+#include "primitives.h"
+
+uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
+{
+ uint_fast8_t count;
+
+ count = 8;
+ if ( 0x100 <= a ) {
+ count = 0;
+ a >>= 8;
+ }
+ count += softfloat_countLeadingZeros8[a];
+ return count;
+
+}
+
+#endif
+
diff --git a/source/s_countLeadingZeros32.c b/source/s_countLeadingZeros32.c
index 4446b47..fb81de3 100644
--- a/source/s_countLeadingZeros32.c
+++ b/source/s_countLeadingZeros32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_countLeadingZeros64.c b/source/s_countLeadingZeros64.c
index 505dc0f..4358830 100644
--- a/source/s_countLeadingZeros64.c
+++ b/source/s_countLeadingZeros64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_countLeadingZeros8.c b/source/s_countLeadingZeros8.c
index ed84ffa..038d3ca 100644
--- a/source/s_countLeadingZeros8.c
+++ b/source/s_countLeadingZeros8.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_eq128.c b/source/s_eq128.c
index 39cfa1e..e3d71d8 100644
--- a/source/s_eq128.c
+++ b/source/s_eq128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_invalidExtF80M.c b/source/s_invalidExtF80M.c
index c5f92db..dcda117 100644
--- a/source/s_invalidExtF80M.c
+++ b/source/s_invalidExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_invalidF128M.c b/source/s_invalidF128M.c
index 45c5aed..ab1dc2b 100644
--- a/source/s_invalidF128M.c
+++ b/source/s_invalidF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_isNaNF128M.c b/source/s_isNaNF128M.c
index 5cc8f31..6e11f1d 100644
--- a/source/s_isNaNF128M.c
+++ b/source/s_isNaNF128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -46,7 +46,7 @@ bool softfloat_isNaNF128M( const uint32_t *aWPtr )
uint32_t uiA96;
uiA96 = aWPtr[indexWordHi( 4 )];
- if ( (uiA96 & 0x7FFF0000) != 0x7FFF0000 ) return false;
+ if ( (~uiA96 & 0x7FFF0000) != 0 ) return false;
return
((uiA96 & 0x0000FFFF) != 0)
|| ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
diff --git a/source/s_le128.c b/source/s_le128.c
index 8130200..5b8cf75 100644
--- a/source/s_le128.c
+++ b/source/s_le128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_lt128.c b/source/s_lt128.c
index 394ce39..398ea48 100644
--- a/source/s_lt128.c
+++ b/source/s_lt128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_mul128By32.c b/source/s_mul128By32.c
index aa35cca..7cf071c 100644
--- a/source/s_mul128By32.c
+++ b/source/s_mul128By32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_mul128MTo256M.c b/source/s_mul128MTo256M.c
index e4f343d..ab7ac05 100644
--- a/source/s_mul128MTo256M.c
+++ b/source/s_mul128MTo256M.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -74,23 +74,23 @@ void
(uint64_t) aPtr[indexWord( 4, 1 )] * wordB + (dwordProd>>32);
wordZ = zPtr[indexWord( 5, 1 )] + (uint32_t) dwordProd + carry;
zPtr[indexWord( 5, 1 )] = wordZ;
- carry =
- carry ? (wordZ <= (uint32_t) dwordProd)
- : (wordZ < (uint32_t) dwordProd);
+ if ( wordZ != (uint32_t) dwordProd ) {
+ carry = (wordZ < (uint32_t) dwordProd);
+ }
dwordProd =
(uint64_t) aPtr[indexWord( 4, 2 )] * wordB + (dwordProd>>32);
wordZ = zPtr[indexWord( 5, 2 )] + (uint32_t) dwordProd + carry;
zPtr[indexWord( 5, 2 )] = wordZ;
- carry =
- carry ? (wordZ <= (uint32_t) dwordProd)
- : (wordZ < (uint32_t) dwordProd);
+ if ( wordZ != (uint32_t) dwordProd ) {
+ carry = (wordZ < (uint32_t) dwordProd);
+ }
dwordProd =
(uint64_t) aPtr[indexWord( 4, 3 )] * wordB + (dwordProd>>32);
wordZ = zPtr[indexWord( 5, 3 )] + (uint32_t) dwordProd + carry;
zPtr[indexWord( 5, 3 )] = wordZ;
- carry =
- carry ? (wordZ <= (uint32_t) dwordProd)
- : (wordZ < (uint32_t) dwordProd);
+ if ( wordZ != (uint32_t) dwordProd ) {
+ carry = (wordZ < (uint32_t) dwordProd);
+ }
zPtr[indexWord( 5, 4 )] = (dwordProd>>32) + carry;
} while ( zPtr != lastZPtr );
diff --git a/source/s_mul128To256M.c b/source/s_mul128To256M.c
index be7b02e..ece78f0 100644
--- a/source/s_mul128To256M.c
+++ b/source/s_mul128To256M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_mul64ByShifted32To128.c b/source/s_mul64ByShifted32To128.c
index 8065cb7..6a9ce82 100644
--- a/source/s_mul64ByShifted32To128.c
+++ b/source/s_mul64ByShifted32To128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_mul64To128.c b/source/s_mul64To128.c
index 06beec8..3364259 100644
--- a/source/s_mul64To128.c
+++ b/source/s_mul64To128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_mul64To128M.c b/source/s_mul64To128M.c
index e4a3b1e..a7522f8 100644
--- a/source/s_mul64To128M.c
+++ b/source/s_mul64To128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_mulAddF128.c b/source/s_mulAddF128.c
index 34424a2..df2b6f6 100644
--- a/source/s_mulAddF128.c
+++ b/source/s_mulAddF128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -68,7 +68,7 @@ float128_t
int_fast32_t expZ;
uint64_t sig256Z[4];
struct uint128 sigZ;
- int_fast32_t shiftCount, expDiff;
+ int_fast32_t shiftDist, expDiff;
struct uint128 x128;
uint64_t sig256C[4];
static uint64_t zero256[4] = INIT_UINTM4( 0, 0, 0, 0 );
@@ -140,14 +140,14 @@ float128_t
softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
sigZ.v64 = sig256Z[indexWord( 4, 3 )];
sigZ.v0 = sig256Z[indexWord( 4, 2 )];
- shiftCount = 0;
+ shiftDist = 0;
if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
--expZ;
- shiftCount = -1;
+ shiftDist = -1;
}
if ( ! expC ) {
if ( ! (sigC.v64 | sigC.v0) ) {
- shiftCount += 8;
+ shiftDist += 8;
goto sigZ;
}
normExpSig = softfloat_normSubnormalF128Sig( sigC.v64, sigC.v0 );
@@ -162,14 +162,13 @@ float128_t
if ( expDiff < 0 ) {
expZ = expC;
if ( (signZ == signC) || (expDiff < -1) ) {
- shiftCount -= expDiff;
- if ( shiftCount ) {
+ shiftDist -= expDiff;
+ if ( shiftDist ) {
sigZ =
- softfloat_shiftRightJam128(
- sigZ.v64, sigZ.v0, shiftCount );
+ softfloat_shiftRightJam128( sigZ.v64, sigZ.v0, shiftDist );
}
} else {
- if ( ! shiftCount ) {
+ if ( ! shiftDist ) {
x128 =
softfloat_shortShiftRight128(
sig256Z[indexWord( 4, 1 )], sig256Z[indexWord( 4, 0 )],
@@ -183,7 +182,7 @@ float128_t
}
}
} else {
- if ( shiftCount ) softfloat_add256M( sig256Z, sig256Z, sig256Z );
+ if ( shiftDist ) softfloat_add256M( sig256Z, sig256Z, sig256Z );
if ( ! expDiff ) {
sigZ.v64 = sig256Z[indexWord( 4, 3 )];
sigZ.v0 = sig256Z[indexWord( 4, 2 )];
@@ -197,7 +196,7 @@ float128_t
}
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
- shiftCount = 8;
+ shiftDist = 8;
if ( signZ == signC ) {
/*--------------------------------------------------------------------
*--------------------------------------------------------------------*/
@@ -210,7 +209,7 @@ float128_t
}
if ( sigZ.v64 & UINT64_C( 0x0200000000000000 ) ) {
++expZ;
- shiftCount = 9;
+ shiftDist = 9;
}
} else {
/*--------------------------------------------------------------------
@@ -227,7 +226,7 @@ float128_t
}
if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
--expZ;
- shiftCount = 7;
+ shiftDist = 7;
}
goto shiftRightRoundPack;
} else {
@@ -248,7 +247,7 @@ float128_t
sig256Z[indexWord( 4, 3 )] = sigZ.v64;
sig256Z[indexWord( 4, 2 )] = sigZ.v0;
if ( sigZ.v64 & UINT64_C( 0x8000000000000000 ) ) {
- signZ ^= 1;
+ signZ = ! signZ;
softfloat_sub256M( zero256, sig256Z, sig256Z );
}
} else {
@@ -258,7 +257,7 @@ float128_t
sigZ.v0 = sig256Z[indexWord( 4, 2 )];
if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
--expZ;
- shiftCount = 7;
+ shiftDist = 7;
}
goto sigZ;
}
@@ -288,15 +287,14 @@ float128_t
}
}
}
- shiftCount = softfloat_countLeadingZeros64( sigZ.v64 );
- expZ += 7 - shiftCount;
- shiftCount = 15 - shiftCount;
- if ( 0 < shiftCount ) goto shiftRightRoundPack;
- if ( shiftCount ) {
- shiftCount = -shiftCount;
- sigZ =
- softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, shiftCount );
- x128 = softfloat_shortShiftLeft128( 0, sigZExtra, shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sigZ.v64 );
+ expZ += 7 - shiftDist;
+ shiftDist = 15 - shiftDist;
+ if ( 0 < shiftDist ) goto shiftRightRoundPack;
+ if ( shiftDist ) {
+ shiftDist = -shiftDist;
+ sigZ = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, shiftDist );
+ x128 = softfloat_shortShiftLeft128( 0, sigZExtra, shiftDist );
sigZ.v0 |= x128.v64;
sigZExtra = x128.v0;
}
@@ -305,8 +303,8 @@ float128_t
sigZ:
sigZExtra = sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
shiftRightRoundPack:
- sigZExtra = (uint64_t) (sigZ.v0<<(64 - shiftCount)) | (sigZExtra != 0);
- sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, shiftCount );
+ sigZExtra = (uint64_t) (sigZ.v0<<(64 - shiftDist)) | (sigZExtra != 0);
+ sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, shiftDist );
roundPack:
return
softfloat_roundPackToF128(
@@ -326,7 +324,6 @@ float128_t
if ( sigC.v64 | sigC.v0 ) goto propagateNaN_ZC;
if ( signZ == signC ) goto uiZ;
}
- invalid:
softfloat_raiseFlags( softfloat_flag_invalid );
uiZ.v64 = defaultNaNF128UI64;
uiZ.v0 = defaultNaNF128UI0;
@@ -342,7 +339,7 @@ float128_t
completeCancellation:
uiZ.v64 =
packToF128UI64(
- softfloat_roundingMode == softfloat_round_min, 0, 0 );
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
uiZ.v0 = 0;
}
uiZ:
diff --git a/source/s_mulAddF128M.c b/source/s_mulAddF128M.c
index fc34992..9c9b13f 100644
--- a/source/s_mulAddF128M.c
+++ b/source/s_mulAddF128M.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -59,7 +59,7 @@ void
int32_t expC;
bool signProd, prodIsInfinite;
uint32_t *ptr, uiZ96, sigA[4];
- uint_fast8_t shiftCount;
+ uint_fast8_t shiftDist;
uint32_t sigX[5];
int32_t expProd;
uint32_t sigProd[8], wordSig;
@@ -242,9 +242,9 @@ void
} else {
/*----------------------------------------------------------------
*----------------------------------------------------------------*/
- shiftCount = expDiff & 31;
- if ( shiftCount ) {
- softfloat_shortShiftRight160M( sigX, shiftCount, sigX );
+ shiftDist = expDiff & 31;
+ if ( shiftDist ) {
+ softfloat_shortShiftRight160M( sigX, shiftDist, sigX );
}
expDiff >>= 5;
extSigPtr =
diff --git a/source/s_mulAddF16.c b/source/s_mulAddF16.c
new file mode 100644
index 0000000..541a395
--- /dev/null
+++ b/source/s_mulAddF16.c
@@ -0,0 +1,226 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t
+ softfloat_mulAddF16(
+ uint_fast16_t uiA, uint_fast16_t uiB, uint_fast16_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ bool signB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ bool signC;
+ int_fast8_t expC;
+ uint_fast16_t sigC;
+ bool signProd;
+ uint_fast16_t magBits, uiZ;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expProd;
+ uint_fast32_t sigProd;
+ bool signZ;
+ int_fast8_t expZ;
+ uint_fast16_t sigZ;
+ int_fast8_t expDiff;
+ uint_fast32_t sig32Z, sig32C;
+ int_fast8_t shiftDist;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ signB = signF16UI( uiB );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ signC = signF16UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF16UI( uiC );
+ sigC = fracF16UI( uiC );
+ signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0x1F ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expProd = expA + expB - 0xE;
+ sigA = (sigA | 0x0400)<<4;
+ sigB = (sigB | 0x0400)<<4;
+ sigProd = (uint_fast32_t) sigA * sigB;
+ if ( sigProd < 0x20000000 ) {
+ --expProd;
+ sigProd <<= 1;
+ }
+ signZ = signProd;
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ expZ = expProd - 1;
+ sigZ = sigProd>>15 | ((sigProd & 0x7FFF) != 0);
+ goto roundPack;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | 0x0400)<<3;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expProd - expC;
+ if ( signProd == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ expZ = expC;
+ sigZ = sigC + softfloat_shiftRightJam32( sigProd, 16 - expDiff );
+ } else {
+ expZ = expProd;
+ sig32Z =
+ sigProd
+ + softfloat_shiftRightJam32(
+ (uint_fast32_t) sigC<<16, expDiff );
+ sigZ = sig32Z>>16 | ((sig32Z & 0xFFFF) != 0 );
+ }
+ if ( sigZ < 0x4000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sig32C = (uint_fast32_t) sigC<<16;
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ expZ = expC;
+ sig32Z = sig32C - softfloat_shiftRightJam32( sigProd, -expDiff );
+ } else if ( ! expDiff ) {
+ expZ = expProd;
+ sig32Z = sigProd - sig32C;
+ if ( ! sig32Z ) goto completeCancellation;
+ if ( sig32Z & 0x80000000 ) {
+ signZ = ! signZ;
+ sig32Z = -sig32Z;
+ }
+ } else {
+ expZ = expProd;
+ sig32Z = sigProd - softfloat_shiftRightJam32( sig32C, expDiff );
+ }
+ shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
+ expZ -= shiftDist;
+ shiftDist -= 16;
+ if ( shiftDist < 0 ) {
+ sigZ =
+ sig32Z>>(-shiftDist)
+ | ((uint32_t) (sig32Z<<(shiftDist & 31)) != 0);
+ } else {
+ sigZ = (uint_fast16_t) sig32Z<<shiftDist;
+ }
+ }
+ roundPack:
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN_ABC:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infProdArg:
+ if ( magBits ) {
+ uiZ = packToF16UI( signProd, 0x1F, 0 );
+ if ( expC != 0x1F ) goto uiZ;
+ if ( sigC ) goto propagateNaN_ZC;
+ if ( signProd == signC ) goto uiZ;
+ }
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ propagateNaN_ZC:
+ uiZ = softfloat_propagateNaNF16UI( uiZ, uiC );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zeroProd:
+ uiZ = uiC;
+ if ( ! (expC | sigC) && (signProd != signC) ) {
+ completeCancellation:
+ uiZ =
+ packToF16UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ }
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/s_mulAddF32.c b/source/s_mulAddF32.c
index 7b0ac6f..5da769f 100644
--- a/source/s_mulAddF32.c
+++ b/source/s_mulAddF32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -64,9 +64,11 @@ float32_t
uint_fast32_t sigZ;
int_fast16_t expDiff;
uint_fast64_t sig64Z, sig64C;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
signA = signF32UI( uiA );
expA = expF32UI( uiA );
sigA = fracF32UI( uiA );
@@ -77,6 +79,8 @@ float32_t
expC = expF32UI( uiC );
sigC = fracF32UI( uiC );
signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( expA == 0xFF ) {
if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN_ABC;
magBits = expB | sigB;
@@ -95,6 +99,8 @@ float32_t
uiZ = uiC;
goto uiZ;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
if ( ! expA ) {
if ( ! sigA ) goto zeroProd;
normExpSig = softfloat_normSubnormalF32Sig( sigA );
@@ -107,6 +113,8 @@ float32_t
expB = normExpSig.exp;
sigB = normExpSig.sig;
}
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expProd = expA + expB - 0x7E;
sigA = (sigA | 0x00800000)<<7;
sigB = (sigB | 0x00800000)<<7;
@@ -127,8 +135,12 @@ float32_t
sigC = normExpSig.sig;
}
sigC = (sigC | 0x00800000)<<6;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expDiff = expProd - expC;
if ( signProd == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
if ( expDiff <= 0 ) {
expZ = expC;
sigZ = sigC + softfloat_shiftRightJam64( sigProd, 32 - expDiff );
@@ -145,6 +157,8 @@ float32_t
sigZ <<= 1;
}
} else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
sig64C = (uint_fast64_t) sigC<<32;
if ( expDiff < 0 ) {
signZ = signC;
@@ -155,27 +169,31 @@ float32_t
sig64Z = sigProd - sig64C;
if ( ! sig64Z ) goto completeCancellation;
if ( sig64Z & UINT64_C( 0x8000000000000000 ) ) {
- signZ ^= 1;
+ signZ = ! signZ;
sig64Z = -sig64Z;
}
} else {
expZ = expProd;
sig64Z = sigProd - softfloat_shiftRightJam64( sig64C, expDiff );
}
- shiftCount = softfloat_countLeadingZeros64( sig64Z ) - 1;
- expZ -= shiftCount;
- shiftCount -= 32;
- if ( shiftCount < 0 ) {
- sigZ = softfloat_shortShiftRightJam64( sig64Z, -shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sig64Z ) - 1;
+ expZ -= shiftDist;
+ shiftDist -= 32;
+ if ( shiftDist < 0 ) {
+ sigZ = softfloat_shortShiftRightJam64( sig64Z, -shiftDist );
} else {
- sigZ = (uint_fast32_t) sig64Z<<shiftCount;
+ sigZ = (uint_fast32_t) sig64Z<<shiftDist;
}
}
roundPack:
return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
propagateNaN_ABC:
uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
infProdArg:
if ( magBits ) {
uiZ = packToF32UI( signProd, 0xFF, 0 );
@@ -183,18 +201,20 @@ float32_t
if ( sigC ) goto propagateNaN_ZC;
if ( signProd == signC ) goto uiZ;
}
- invalid:
softfloat_raiseFlags( softfloat_flag_invalid );
uiZ = defaultNaNF32UI;
propagateNaN_ZC:
uiZ = softfloat_propagateNaNF32UI( uiZ, uiC );
goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
zeroProd:
uiZ = uiC;
if ( ! (expC | sigC) && (signProd != signC) ) {
completeCancellation:
uiZ =
- packToF32UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
+ packToF32UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
}
uiZ:
uZ.ui = uiZ;
diff --git a/source/s_mulAddF64.c b/source/s_mulAddF64.c
index 9f9ecf5..b5de29b 100644
--- a/source/s_mulAddF64.c
+++ b/source/s_mulAddF64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -64,7 +64,7 @@ float64_t
uint_fast64_t sigZ;
int_fast16_t expDiff;
struct uint128 sig128C;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui64_f64 uZ;
/*------------------------------------------------------------------------
@@ -177,7 +177,7 @@ float64_t
sig128Z.v64 = sig128Z.v64 - sigC;
if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
- signZ ^= 1;
+ signZ = ! signZ;
sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
}
} else {
@@ -192,14 +192,14 @@ float64_t
sig128Z.v64 = sig128Z.v0;
sig128Z.v0 = 0;
}
- shiftCount = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
- expZ -= shiftCount;
- if ( shiftCount < 0 ) {
- sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
+ expZ -= shiftDist;
+ if ( shiftDist < 0 ) {
+ sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
} else {
sig128Z =
softfloat_shortShiftLeft128(
- sig128Z.v64, sig128Z.v0, shiftCount );
+ sig128Z.v64, sig128Z.v0, shiftDist );
sigZ = sig128Z.v64;
}
sigZ |= (sig128Z.v0 != 0);
@@ -220,7 +220,6 @@ float64_t
if ( sigC ) goto propagateNaN_ZC;
if ( signZ == signC ) goto uiZ;
}
- invalid:
softfloat_raiseFlags( softfloat_flag_invalid );
uiZ = defaultNaNF64UI;
propagateNaN_ZC:
@@ -233,7 +232,8 @@ float64_t
if ( ! (expC | sigC) && (signZ != signC) ) {
completeCancellation:
uiZ =
- packToF64UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
}
uiZ:
uZ.ui = uiZ;
@@ -262,7 +262,7 @@ float64_t
int_fast16_t expZ;
uint32_t sig128Z[4];
uint64_t sigZ;
- int_fast16_t shiftCount, expDiff;
+ int_fast16_t shiftDist, expDiff;
uint32_t sig128C[4];
union ui64_f64 uZ;
@@ -320,14 +320,14 @@ float64_t
softfloat_mul64To128M( sigA, sigB, sig128Z );
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
- shiftCount = 0;
+ shiftDist = 0;
if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
--expZ;
- shiftCount = -1;
+ shiftDist = -1;
}
if ( ! expC ) {
if ( ! sigC ) {
- if ( shiftCount ) sigZ <<= 1;
+ if ( shiftDist ) sigZ <<= 1;
goto sigZ;
}
normExpSig = softfloat_normSubnormalF64Sig( sigC );
@@ -341,17 +341,17 @@ float64_t
if ( expDiff < 0 ) {
expZ = expC;
if ( (signZ == signC) || (expDiff < -1) ) {
- shiftCount -= expDiff;
- if ( shiftCount) {
- sigZ = softfloat_shiftRightJam64( sigZ, shiftCount );
+ shiftDist -= expDiff;
+ if ( shiftDist) {
+ sigZ = softfloat_shiftRightJam64( sigZ, shiftDist );
}
} else {
- if ( ! shiftCount ) {
+ if ( ! shiftDist ) {
softfloat_shortShiftRight128M( sig128Z, 1, sig128Z );
}
}
} else {
- if ( shiftCount ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
+ if ( shiftDist ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
if ( ! expDiff ) {
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32
@@ -416,7 +416,7 @@ float64_t
sig128Z[indexWord( 4, 3 )] = sigZ>>32;
sig128Z[indexWord( 4, 2 )] = sigZ;
if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
- signZ ^= 1;
+ signZ = ! signZ;
softfloat_negX128M( sig128Z );
}
} else {
@@ -434,20 +434,20 @@ float64_t
}
/*--------------------------------------------------------------------
*--------------------------------------------------------------------*/
- shiftCount = 0;
+ shiftDist = 0;
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32
| sig128Z[indexWord( 4, 2 )];
if ( ! sigZ ) {
- shiftCount = 64;
+ shiftDist = 64;
sigZ =
(uint64_t) sig128Z[indexWord( 4, 1 )]<<32
| sig128Z[indexWord( 4, 0 )];
}
- shiftCount += softfloat_countLeadingZeros64( sigZ ) - 1;
- if ( shiftCount ) {
- expZ -= shiftCount;
- softfloat_shiftLeft128M( sig128Z, shiftCount, sig128Z );
+ shiftDist += softfloat_countLeadingZeros64( sigZ ) - 1;
+ if ( shiftDist ) {
+ expZ -= shiftDist;
+ softfloat_shiftLeft128M( sig128Z, shiftDist, sig128Z );
sigZ =
(uint64_t) sig128Z[indexWord( 4, 3 )]<<32
| sig128Z[indexWord( 4, 2 )];
@@ -471,7 +471,6 @@ float64_t
if ( sigC ) goto propagateNaN_ZC;
if ( signZ == signC ) goto uiZ;
}
- invalid:
softfloat_raiseFlags( softfloat_flag_invalid );
uiZ = defaultNaNF64UI;
propagateNaN_ZC:
@@ -484,7 +483,8 @@ float64_t
if ( ! (expC | sigC) && (signZ != signC) ) {
completeCancellation:
uiZ =
- packToF64UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
}
uiZ:
uZ.ui = uiZ;
diff --git a/source/s_negXM.c b/source/s_negXM.c
index 4c80aa9..21a8bfb 100644
--- a/source/s_negXM.c
+++ b/source/s_negXM.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_normExtF80SigM.c b/source/s_normExtF80SigM.c
index bf1d622..0fc70a0 100644
--- a/source/s_normExtF80SigM.c
+++ b/source/s_normExtF80SigM.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -41,12 +41,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int softfloat_normExtF80SigM( uint64_t *sigPtr )
{
uint64_t sig;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
sig = *sigPtr;
- shiftCount = softfloat_countLeadingZeros64( sig );
- *sigPtr = sig<<shiftCount;
- return -shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( sig );
+ *sigPtr = sig<<shiftDist;
+ return -shiftDist;
}
diff --git a/source/s_normRoundPackMToExtF80M.c b/source/s_normRoundPackMToExtF80M.c
index 00e2e5a..51845c5 100644
--- a/source/s_normRoundPackMToExtF80M.c
+++ b/source/s_normRoundPackMToExtF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -48,16 +48,16 @@ void
struct extFloat80M *zSPtr
)
{
- int_fast16_t shiftCount;
+ int_fast16_t shiftDist;
uint32_t wordSig;
- shiftCount = 0;
+ shiftDist = 0;
wordSig = extSigPtr[indexWord( 3, 2 )];
if ( ! wordSig ) {
- shiftCount = 32;
+ shiftDist = 32;
wordSig = extSigPtr[indexWord( 3, 1 )];
if ( ! wordSig ) {
- shiftCount = 64;
+ shiftDist = 64;
wordSig = extSigPtr[indexWord( 3, 0 )];
if ( ! wordSig ) {
zSPtr->signExp = packToExtF80UI64( sign, 0 );
@@ -66,10 +66,10 @@ void
}
}
}
- shiftCount += softfloat_countLeadingZeros32( wordSig );
- if ( shiftCount ) {
- exp -= shiftCount;
- softfloat_shiftLeft96M( extSigPtr, shiftCount, extSigPtr );
+ shiftDist += softfloat_countLeadingZeros32( wordSig );
+ if ( shiftDist ) {
+ exp -= shiftDist;
+ softfloat_shiftLeft96M( extSigPtr, shiftDist, extSigPtr );
}
softfloat_roundPackMToExtF80M(
sign, exp, extSigPtr, roundingPrecision, zSPtr );
diff --git a/source/s_normRoundPackMToF128M.c b/source/s_normRoundPackMToF128M.c
index 0064cc2..f7085f2 100644
--- a/source/s_normRoundPackMToF128M.c
+++ b/source/s_normRoundPackMToF128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -44,16 +44,16 @@ void
bool sign, int32_t exp, uint32_t *extSigPtr, uint32_t *zWPtr )
{
const uint32_t *ptr;
- int_fast16_t shiftCount;
+ int_fast16_t shiftDist;
uint32_t wordSig;
ptr = extSigPtr + indexWordHi( 5 );
- shiftCount = 0;
+ shiftDist = 0;
for (;;) {
wordSig = *ptr;
if ( wordSig ) break;
- shiftCount += 32;
- if ( 160 <= shiftCount ) {
+ shiftDist += 32;
+ if ( 160 <= shiftDist ) {
zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, 0, 0 );
zWPtr[indexWord( 4, 2 )] = 0;
zWPtr[indexWord( 4, 1 )] = 0;
@@ -62,10 +62,10 @@ void
}
ptr -= wordIncr;
}
- shiftCount += softfloat_countLeadingZeros32( wordSig ) - 15;
- if ( shiftCount ) {
- exp -= shiftCount;
- softfloat_shiftLeft160M( extSigPtr, shiftCount, extSigPtr );
+ shiftDist += softfloat_countLeadingZeros32( wordSig ) - 15;
+ if ( shiftDist ) {
+ exp -= shiftDist;
+ softfloat_shiftLeft160M( extSigPtr, shiftDist, extSigPtr );
}
softfloat_roundPackMToF128M( sign, exp, extSigPtr, zWPtr );
diff --git a/source/s_normRoundPackToExtF80.c b/source/s_normRoundPackToExtF80.c
index 66b878b..36a11a2 100644
--- a/source/s_normRoundPackToExtF80.c
+++ b/source/s_normRoundPackToExtF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -48,7 +48,7 @@ extFloat80_t
uint_fast8_t roundingPrecision
)
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct uint128 sig128;
if ( ! sig ) {
@@ -56,10 +56,10 @@ extFloat80_t
sig = sigExtra;
sigExtra = 0;
}
- shiftCount = softfloat_countLeadingZeros64( sig );
- exp -= shiftCount;
- if ( shiftCount ) {
- sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sig );
+ exp -= shiftDist;
+ if ( shiftDist ) {
+ sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
sig = sig128.v64;
sigExtra = sig128.v0;
}
diff --git a/source/s_normRoundPackToF128.c b/source/s_normRoundPackToF128.c
index bb44f65..1142422 100644
--- a/source/s_normRoundPackToF128.c
+++ b/source/s_normRoundPackToF128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -43,7 +43,7 @@ float128_t
softfloat_normRoundPackToF128(
bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0 )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct uint128 sig128;
union ui128_f128 uZ;
uint_fast64_t sigExtra;
@@ -54,11 +54,11 @@ float128_t
sig64 = sig0;
sig0 = 0;
}
- shiftCount = softfloat_countLeadingZeros64( sig64 ) - 15;
- exp -= shiftCount;
- if ( 0 <= shiftCount ) {
- if ( shiftCount ) {
- sig128 = softfloat_shortShiftLeft128( sig64, sig0, shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
+ exp -= shiftDist;
+ if ( 0 <= shiftDist ) {
+ if ( shiftDist ) {
+ sig128 = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
sig64 = sig128.v64;
sig0 = sig128.v0;
}
@@ -70,8 +70,7 @@ float128_t
sigExtra = 0;
} else {
sig128Extra =
- softfloat_shortShiftRightJam128Extra(
- sig64, sig0, 0, -shiftCount );
+ softfloat_shortShiftRightJam128Extra( sig64, sig0, 0, -shiftDist );
sig64 = sig128Extra.v.v64;
sig0 = sig128Extra.v.v0;
sigExtra = sig128Extra.extra;
diff --git a/source/s_normRoundPackToF16.c b/source/s_normRoundPackToF16.c
new file mode 100644
index 0000000..32de028
--- /dev/null
+++ b/source/s_normRoundPackToF16.c
@@ -0,0 +1,58 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+
+float16_t
+ softfloat_normRoundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
+{
+ int_fast8_t shiftDist;
+ union ui16_f16 uZ;
+
+ shiftDist = softfloat_countLeadingZeros16( sig ) - 1;
+ exp -= shiftDist;
+ if ( (4 <= shiftDist) && ((unsigned int) exp < 0x1D) ) {
+ uZ.ui = packToF16UI( sign, sig ? exp : 0, sig<<(shiftDist - 4) );
+ return uZ.f;
+ } else {
+ return softfloat_roundPackToF16( sign, exp, sig<<shiftDist );
+ }
+
+}
+
diff --git a/source/s_normRoundPackToF32.c b/source/s_normRoundPackToF32.c
index fea073c..296ce6e 100644
--- a/source/s_normRoundPackToF32.c
+++ b/source/s_normRoundPackToF32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,16 +42,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
float32_t
softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui32_f32 uZ;
- shiftCount = softfloat_countLeadingZeros32( sig ) - 1;
- exp -= shiftCount;
- if ( (7 <= shiftCount) && ((uint16_t) exp < 0xFD) ) {
- uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<(shiftCount - 7) );
+ shiftDist = softfloat_countLeadingZeros32( sig ) - 1;
+ exp -= shiftDist;
+ if ( (7 <= shiftDist) && ((unsigned int) exp < 0xFD) ) {
+ uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<(shiftDist - 7) );
return uZ.f;
} else {
- return softfloat_roundPackToF32( sign, exp, sig<<shiftCount );
+ return softfloat_roundPackToF32( sign, exp, sig<<shiftDist );
}
}
diff --git a/source/s_normRoundPackToF64.c b/source/s_normRoundPackToF64.c
index dd42fc8..aa42570 100644
--- a/source/s_normRoundPackToF64.c
+++ b/source/s_normRoundPackToF64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,16 +42,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
float64_t
softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui64_f64 uZ;
- shiftCount = softfloat_countLeadingZeros64( sig ) - 1;
- exp -= shiftCount;
- if ( (10 <= shiftCount) && ((uint16_t) exp < 0x7FD) ) {
- uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftCount - 10) );
+ shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
+ exp -= shiftDist;
+ if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
+ uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) );
return uZ.f;
} else {
- return softfloat_roundPackToF64( sign, exp, sig<<shiftCount );
+ return softfloat_roundPackToF64( sign, exp, sig<<shiftDist );
}
}
diff --git a/source/s_normSubnormalExtF80Sig.c b/source/s_normSubnormalExtF80Sig.c
index 09eb42f..7826b6c 100644
--- a/source/s_normSubnormalExtF80Sig.c
+++ b/source/s_normSubnormalExtF80Sig.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,12 +40,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t sig )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct exp32_sig64 z;
- shiftCount = softfloat_countLeadingZeros64( sig );
- z.exp = -shiftCount;
- z.sig = sig<<shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( sig );
+ z.exp = -shiftDist;
+ z.sig = sig<<shiftDist;
return z;
}
diff --git a/source/s_normSubnormalF128Sig.c b/source/s_normSubnormalF128Sig.c
index 3e8cf28..c58091e 100644
--- a/source/s_normSubnormalF128Sig.c
+++ b/source/s_normSubnormalF128Sig.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -41,23 +41,23 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct exp32_sig128
softfloat_normSubnormalF128Sig( uint_fast64_t sig64, uint_fast64_t sig0 )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct exp32_sig128 z;
if ( ! sig64 ) {
- shiftCount = softfloat_countLeadingZeros64( sig0 ) - 15;
- z.exp = -63 - shiftCount;
- if ( shiftCount < 0 ) {
- z.sig.v64 = sig0>>-shiftCount;
- z.sig.v0 = sig0<<(shiftCount & 63);
+ shiftDist = softfloat_countLeadingZeros64( sig0 ) - 15;
+ z.exp = -63 - shiftDist;
+ if ( shiftDist < 0 ) {
+ z.sig.v64 = sig0>>-shiftDist;
+ z.sig.v0 = sig0<<(shiftDist & 63);
} else {
- z.sig.v64 = sig0<<shiftCount;
+ z.sig.v64 = sig0<<shiftDist;
z.sig.v0 = 0;
}
} else {
- shiftCount = softfloat_countLeadingZeros64( sig64 ) - 15;
- z.exp = 1 - shiftCount;
- z.sig = softfloat_shortShiftLeft128( sig64, sig0, shiftCount );
+ shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
+ z.exp = 1 - shiftDist;
+ z.sig = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
}
return z;
diff --git a/source/s_normSubnormalF128SigM.c b/source/s_normSubnormalF128SigM.c
index f06eac9..284a92f 100644
--- a/source/s_normSubnormalF128SigM.c
+++ b/source/s_normSubnormalF128SigM.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -41,21 +41,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int softfloat_normSubnormalF128SigM( uint32_t *sigPtr )
{
const uint32_t *ptr;
- int_fast16_t shiftCount;
+ int_fast16_t shiftDist;
uint32_t wordSig;
ptr = sigPtr + indexWordHi( 4 );
- shiftCount = 0;
+ shiftDist = 0;
for (;;) {
wordSig = *ptr;
if ( wordSig ) break;
- shiftCount += 32;
- if ( 128 <= shiftCount ) return 1;
+ shiftDist += 32;
+ if ( 128 <= shiftDist ) return 1;
ptr -= wordIncr;
}
- shiftCount += softfloat_countLeadingZeros32( wordSig ) - 15;
- if ( shiftCount ) softfloat_shiftLeft128M( sigPtr, shiftCount, sigPtr );
- return 1 - shiftCount;
+ shiftDist += softfloat_countLeadingZeros32( wordSig ) - 15;
+ if ( shiftDist ) softfloat_shiftLeft128M( sigPtr, shiftDist, sigPtr );
+ return 1 - shiftDist;
}
diff --git a/source/s_normSubnormalF16Sig.c b/source/s_normSubnormalF16Sig.c
new file mode 100644
index 0000000..1e91114
--- /dev/null
+++ b/source/s_normSubnormalF16Sig.c
@@ -0,0 +1,52 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+
+struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp8_sig16 z;
+
+ shiftDist = softfloat_countLeadingZeros16( sig ) - 5;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<<shiftDist;
+ return z;
+
+}
+
diff --git a/source/s_normSubnormalF32Sig.c b/source/s_normSubnormalF32Sig.c
index 3948eb7..1e1220c 100644
--- a/source/s_normSubnormalF32Sig.c
+++ b/source/s_normSubnormalF32Sig.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,12 +40,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct exp16_sig32 z;
- shiftCount = softfloat_countLeadingZeros32( sig ) - 8;
- z.exp = 1 - shiftCount;
- z.sig = sig<<shiftCount;
+ shiftDist = softfloat_countLeadingZeros32( sig ) - 8;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<<shiftDist;
return z;
}
diff --git a/source/s_normSubnormalF64Sig.c b/source/s_normSubnormalF64Sig.c
index e9234e9..ac5ac96 100644
--- a/source/s_normSubnormalF64Sig.c
+++ b/source/s_normSubnormalF64Sig.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,12 +40,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct exp16_sig64 z;
- shiftCount = softfloat_countLeadingZeros64( sig ) - 11;
- z.exp = 1 - shiftCount;
- z.sig = sig<<shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<<shiftDist;
return z;
}
diff --git a/source/s_remStepMBy32.c b/source/s_remStepMBy32.c
index 429d3dc..2849d94 100644
--- a/source/s_remStepMBy32.c
+++ b/source/s_remStepMBy32.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -44,34 +44,33 @@ void
softfloat_remStepMBy32(
uint_fast8_t size_words,
const uint32_t *remPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
const uint32_t *bPtr,
uint32_t q,
uint32_t *zPtr
)
{
- uint_fast8_t negCount;
unsigned int index, lastIndex;
uint64_t dwordProd;
uint32_t wordRem, wordShiftedRem, wordProd;
- uint_fast8_t borrow;
+ uint_fast8_t uNegDist, borrow;
- negCount = -count;
index = indexWordLo( size_words );
lastIndex = indexWordHi( size_words );
dwordProd = (uint64_t) bPtr[index] * q;
wordRem = remPtr[index];
- wordShiftedRem = wordRem<<count;
+ wordShiftedRem = wordRem<<dist;
wordProd = dwordProd;
zPtr[index] = wordShiftedRem - wordProd;
if ( index != lastIndex ) {
+ uNegDist = -dist;
borrow = (wordShiftedRem < wordProd);
for (;;) {
- wordShiftedRem = wordRem>>(negCount & 31);
+ wordShiftedRem = wordRem>>(uNegDist & 31);
index += wordIncr;
dwordProd = (uint64_t) bPtr[index] * q + (dwordProd>>32);
wordRem = remPtr[index];
- wordShiftedRem |= wordRem<<count;
+ wordShiftedRem |= wordRem<<dist;
wordProd = dwordProd;
zPtr[index] = wordShiftedRem - wordProd - borrow;
if ( index == lastIndex ) break;
diff --git a/source/s_roundPackMToExtF80M.c b/source/s_roundPackMToExtF80M.c
index e2ffa16..2326054 100644
--- a/source/s_roundPackMToExtF80M.c
+++ b/source/s_roundPackMToExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_roundPackMToF128M.c b/source/s_roundPackMToF128M.c
index 9e0c77b..f36ca8d 100644
--- a/source/s_roundPackMToF128M.c
+++ b/source/s_roundPackMToF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_roundPackMToI64.c b/source/s_roundPackMToI64.c
index 4d5efbb..d49155a 100644
--- a/source/s_roundPackMToI64.c
+++ b/source/s_roundPackMToI64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_roundPackMToUI64.c b/source/s_roundPackMToUI64.c
index 1a64fdf..664e145 100644
--- a/source/s_roundPackMToUI64.c
+++ b/source/s_roundPackMToUI64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_roundPackToExtF80.c b/source/s_roundPackToExtF80.c
index a2db9a2..d06d57d 100644
--- a/source/s_roundPackToExtF80.c
+++ b/source/s_roundPackToExtF80.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_roundPackToF128.c b/source/s_roundPackToF128.c
index 4babb78..5ab5e5f 100644
--- a/source/s_roundPackToF128.c
+++ b/source/s_roundPackToF128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_roundPackToF16.c b/source/s_roundPackToF16.c
new file mode 100644
index 0000000..f85b0bd
--- /dev/null
+++ b/source/s_roundPackToF16.c
@@ -0,0 +1,91 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t
+ softfloat_roundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast8_t roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast16_t uiZ;
+ union ui16_f16 uZ;
+
+ roundingMode = softfloat_roundingMode;
+ roundNearEven = (roundingMode == softfloat_round_near_even);
+ roundIncrement = 0x8;
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ? 0xF
+ : 0;
+ }
+ roundBits = sig & 0xF;
+ if ( 0x1D <= (unsigned int) exp ) {
+ if ( exp < 0 ) {
+ isTiny =
+ (softfloat_detectTininess == softfloat_tininess_beforeRounding)
+ || (exp < -1) || (sig + roundIncrement < 0x8000);
+ sig = softfloat_shiftRightJam32( sig, -exp );
+ exp = 0;
+ roundBits = sig & 0xF;
+ if ( isTiny && roundBits ) {
+ softfloat_raiseFlags( softfloat_flag_underflow );
+ }
+ } else if ( (0x1D < exp) || (0x8000 <= sig + roundIncrement) ) {
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ uiZ = packToF16UI( sign, 0x1F, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ if ( roundBits ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ sig = (sig + roundIncrement)>>4;
+ sig &= ~(uint_fast16_t) (! (roundBits ^ 8) & roundNearEven);
+ uiZ = packToF16UI( sign, sig ? exp : 0, sig );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/s_roundPackToF32.c b/source/s_roundPackToF32.c
index 8b44a03..aa4638d 100644
--- a/source/s_roundPackToF32.c
+++ b/source/s_roundPackToF32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
@@ -61,13 +61,11 @@ float32_t
: 0;
}
roundBits = sig & 0x7F;
- if ( 0xFD <= (uint16_t) exp ) {
+ if ( 0xFD <= (unsigned int) exp ) {
if ( exp < 0 ) {
isTiny =
- (softfloat_detectTininess
- == softfloat_tininess_beforeRounding)
- || (exp < -1)
- || (sig + roundIncrement < 0x80000000);
+ (softfloat_detectTininess == softfloat_tininess_beforeRounding)
+ || (exp < -1) || (sig + roundIncrement < 0x80000000);
sig = softfloat_shiftRightJam32( sig, -exp );
exp = 0;
roundBits = sig & 0x7F;
diff --git a/source/s_roundPackToF64.c b/source/s_roundPackToF64.c
index e56493e..158192b 100644
--- a/source/s_roundPackToF64.c
+++ b/source/s_roundPackToF64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
@@ -64,10 +64,9 @@ float64_t
if ( 0x7FD <= (uint16_t) exp ) {
if ( exp < 0 ) {
isTiny =
- (softfloat_detectTininess
- == softfloat_tininess_beforeRounding)
- || (exp < -1)
- || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
+ (softfloat_detectTininess == softfloat_tininess_beforeRounding)
+ || (exp < -1)
+ || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
sig = softfloat_shiftRightJam64( sig, -exp );
exp = 0;
roundBits = sig & 0x3FF;
diff --git a/source/s_roundPackToI32.c b/source/s_roundPackToI32.c
index 3ece8f0..e0bf4f4 100644
--- a/source/s_roundPackToI32.c
+++ b/source/s_roundPackToI32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -46,7 +46,7 @@ int_fast32_t
bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
{
bool roundNearEven;
- uint_fast8_t roundIncrement, roundBits;
+ uint_fast16_t roundIncrement, roundBits;
uint_fast32_t sig32;
union { uint32_t ui; int32_t i; } uZ;
int_fast32_t z;
@@ -54,19 +54,19 @@ int_fast32_t
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
roundNearEven = (roundingMode == softfloat_round_near_even);
- roundIncrement = 0x40;
+ roundIncrement = 0x800;
if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
roundIncrement =
(roundingMode
== (sign ? softfloat_round_min : softfloat_round_max))
- ? 0x7F
+ ? 0xFFF
: 0;
}
- roundBits = sig & 0x7F;
+ roundBits = sig & 0xFFF;
sig += roundIncrement;
- if ( sig & UINT64_C( 0xFFFFFF8000000000 ) ) goto invalid;
- sig32 = sig>>7;
- sig32 &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
+ if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
+ sig32 = sig>>12;
+ sig32 &= ~(uint_fast32_t) (! (roundBits ^ 0x800) & roundNearEven);
uZ.ui = sign ? -sig32 : sig32;
z = uZ.i;
if ( z && ((z < 0) ^ sign) ) goto invalid;
diff --git a/source/s_roundPackToI64.c b/source/s_roundPackToI64.c
index ebef7f3..a420826 100644
--- a/source/s_roundPackToI64.c
+++ b/source/s_roundPackToI64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_roundPackToUI32.c b/source/s_roundPackToUI32.c
index f0021fe..22734aa 100644
--- a/source/s_roundPackToUI32.c
+++ b/source/s_roundPackToUI32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
@@ -46,25 +46,25 @@ uint_fast32_t
bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
{
bool roundNearEven;
- uint_fast8_t roundIncrement, roundBits;
+ uint_fast16_t roundIncrement, roundBits;
uint_fast32_t z;
/*------------------------------------------------------------------------
*------------------------------------------------------------------------*/
roundNearEven = (roundingMode == softfloat_round_near_even);
- roundIncrement = 0x40;
+ roundIncrement = 0x800;
if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
roundIncrement =
(roundingMode
== (sign ? softfloat_round_min : softfloat_round_max))
- ? 0x7F
+ ? 0xFFF
: 0;
}
- roundBits = sig & 0x7F;
+ roundBits = sig & 0xFFF;
sig += roundIncrement;
- if ( sig & UINT64_C( 0xFFFFFF8000000000 ) ) goto invalid;
- z = sig>>7;
- z &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
+ if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
+ z = sig>>12;
+ z &= ~(uint_fast32_t) (! (roundBits ^ 0x800) & roundNearEven);
if ( sign && z ) goto invalid;
if ( exact && roundBits ) {
softfloat_exceptionFlags |= softfloat_flag_inexact;
diff --git a/source/s_roundPackToUI64.c b/source/s_roundPackToUI64.c
index fada184..ed41153 100644
--- a/source/s_roundPackToUI64.c
+++ b/source/s_roundPackToUI64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a+, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_shiftLeftM.c b/source/s_shiftLeftM.c
index defa14c..de12610 100644
--- a/source/s_shiftLeftM.c
+++ b/source/s_shiftLeftM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -46,44 +46,44 @@ void
softfloat_shiftLeftM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint32_t count,
+ uint32_t dist,
uint32_t *zPtr
)
{
- uint32_t wordCount;
- uint_fast8_t innerCount;
+ uint32_t wordDist;
+ uint_fast8_t innerDist;
uint32_t *destPtr;
uint_fast8_t i;
- wordCount = count>>5;
- if ( wordCount < size_words ) {
- aPtr += indexMultiwordLoBut( size_words, wordCount );
- innerCount = count & 31;
- if ( innerCount ) {
+ wordDist = dist>>5;
+ if ( wordDist < size_words ) {
+ aPtr += indexMultiwordLoBut( size_words, wordDist );
+ innerDist = dist & 31;
+ if ( innerDist ) {
softfloat_shortShiftLeftM(
- size_words - wordCount,
+ size_words - wordDist,
aPtr,
- innerCount,
- zPtr + indexMultiwordHiBut( size_words, wordCount )
+ innerDist,
+ zPtr + indexMultiwordHiBut( size_words, wordDist )
);
- if ( ! wordCount ) return;
+ if ( ! wordDist ) return;
} else {
- aPtr += indexWordHi( size_words - wordCount );
+ aPtr += indexWordHi( size_words - wordDist );
destPtr = zPtr + indexWordHi( size_words );
- for ( i = size_words - wordCount; i; --i ) {
+ for ( i = size_words - wordDist; i; --i ) {
*destPtr = *aPtr;
aPtr -= wordIncr;
destPtr -= wordIncr;
}
}
- zPtr += indexMultiwordLo( size_words, wordCount );
+ zPtr += indexMultiwordLo( size_words, wordDist );
} else {
- wordCount = size_words;
+ wordDist = size_words;
}
do {
*zPtr++ = 0;
- --wordCount;
- } while ( wordCount );
+ --wordDist;
+ } while ( wordDist );
}
diff --git a/source/s_shiftNormSigF128M.c b/source/s_shiftNormSigF128M.c
index 4d8ded1..ddd913c 100644
--- a/source/s_shiftNormSigF128M.c
+++ b/source/s_shiftNormSigF128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,7 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
int
softfloat_shiftNormSigF128M(
- const uint32_t *wPtr, uint_fast8_t shiftCount, uint32_t *sigPtr )
+ const uint32_t *wPtr, uint_fast8_t shiftDist, uint32_t *sigPtr )
{
uint32_t wordSig;
int32_t exp;
@@ -49,8 +49,8 @@ int
wordSig = wPtr[indexWordHi( 4 )];
exp = expF128UI96( wordSig );
if ( exp ) {
- softfloat_shortShiftLeft128M( wPtr, shiftCount, sigPtr );
- leadingBit = 0x00010000<<shiftCount;
+ softfloat_shortShiftLeft128M( wPtr, shiftDist, sigPtr );
+ leadingBit = 0x00010000<<shiftDist;
sigPtr[indexWordHi( 4 )] =
(sigPtr[indexWordHi( 4 )] & (leadingBit - 1)) | leadingBit;
} else {
@@ -70,7 +70,7 @@ int
}
}
exp -= softfloat_countLeadingZeros32( wordSig );
- softfloat_shiftLeft128M( wPtr, 1 - exp + shiftCount, sigPtr );
+ softfloat_shiftLeft128M( wPtr, 1 - exp + shiftDist, sigPtr );
}
return exp;
diff --git a/source/s_shiftRightJam128.c b/source/s_shiftRightJam128.c
index 4e8a88f..ad6018e 100644
--- a/source/s_shiftRightJam128.c
+++ b/source/s_shiftRightJam128.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -41,23 +41,23 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shiftRightJam128
struct uint128
- softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t count )
+ softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist )
{
- int_fast32_t negCount;
+ uint_fast8_t u8NegDist;
struct uint128 z;
- if ( count < 64 ) {
- negCount = -count;
- z.v64 = a64>>count;
+ if ( dist < 64 ) {
+ u8NegDist = -dist;
+ z.v64 = a64>>dist;
z.v0 =
- a64<<(negCount & 63) | a0>>count
- | ((uint64_t) (a0<<(negCount & 63)) != 0);
+ a64<<(u8NegDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(u8NegDist & 63)) != 0);
} else {
z.v64 = 0;
z.v0 =
- (count < 127)
- ? a64>>(count & 63)
- | (((a64 & (((uint_fast64_t) 1<<(count & 63)) - 1)) | a0)
+ (dist < 127)
+ ? a64>>(dist & 63)
+ | (((a64 & (((uint_fast64_t) 1<<(dist & 63)) - 1)) | a0)
!= 0)
: ((a64 | a0) != 0);
}
diff --git a/source/s_shiftRightJam128Extra.c b/source/s_shiftRightJam128Extra.c
index fb14ef8..ead9448 100644
--- a/source/s_shiftRightJam128Extra.c
+++ b/source/s_shiftRightJam128Extra.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,29 +42,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct uint128_extra
softfloat_shiftRightJam128Extra(
- uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t count )
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist )
{
- int_fast32_t negCount;
+ uint_fast8_t u8NegDist;
struct uint128_extra z;
- negCount = -count;
- if ( count < 64 ) {
- z.v.v64 = a64>>count;
- z.v.v0 = a64<<(negCount & 63) | a0>>count;
- z.extra = a0<<(negCount & 63);
+ u8NegDist = -dist;
+ if ( dist < 64 ) {
+ z.v.v64 = a64>>dist;
+ z.v.v0 = a64<<(u8NegDist & 63) | a0>>dist;
+ z.extra = a0<<(u8NegDist & 63);
} else {
z.v.v64 = 0;
- if ( count == 64 ) {
+ if ( dist == 64 ) {
z.v.v0 = a64;
z.extra = a0;
} else {
extra |= a0;
- if ( count < 128 ) {
- z.v.v0 = a64>>(count & 63);
- z.extra = a64<<(negCount & 63);
+ if ( dist < 128 ) {
+ z.v.v0 = a64>>(dist & 63);
+ z.extra = a64<<(u8NegDist & 63);
} else {
z.v.v0 = 0;
- z.extra = (count == 128) ? a64 : (a64 != 0);
+ z.extra = (dist == 128) ? a64 : (a64 != 0);
}
}
}
diff --git a/source/s_shiftRightJam256M.c b/source/s_shiftRightJam256M.c
index b9d88a2..ec25b55 100644
--- a/source/s_shiftRightJam256M.c
+++ b/source/s_shiftRightJam256M.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -45,25 +45,25 @@ static
softfloat_shortShiftRightJamM(
uint_fast8_t size_words,
const uint64_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint64_t *zPtr
)
{
- uint_fast8_t negCount;
+ uint_fast8_t uNegDist;
unsigned int index, lastIndex;
uint64_t partWordZ, wordA;
- negCount = -count;
+ uNegDist = -dist;
index = indexWordLo( size_words );
lastIndex = indexWordHi( size_words );
wordA = aPtr[index];
- partWordZ = wordA>>count;
- if ( partWordZ<<count != wordA ) partWordZ |= 1;
+ partWordZ = wordA>>dist;
+ if ( partWordZ<<dist != wordA ) partWordZ |= 1;
while ( index != lastIndex ) {
wordA = aPtr[index + wordIncr];
- zPtr[index] = wordA<<(negCount & 63) | partWordZ;
+ zPtr[index] = wordA<<(uNegDist & 63) | partWordZ;
index += wordIncr;
- partWordZ = wordA>>count;
+ partWordZ = wordA>>dist;
}
zPtr[index] = partWordZ;
@@ -71,19 +71,19 @@ static
void
softfloat_shiftRightJam256M(
- const uint64_t *aPtr, uint_fast32_t count, uint64_t *zPtr )
+ const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr )
{
uint64_t wordJam;
- uint_fast32_t wordCount;
+ uint_fast32_t wordDist;
uint64_t *ptr;
- uint_fast8_t i, innerCount;
+ uint_fast8_t i, innerDist;
wordJam = 0;
- wordCount = count>>6;
- if ( wordCount ) {
- if ( 4 < wordCount ) wordCount = 4;
- ptr = (uint64_t *) (aPtr + indexMultiwordLo( 4, wordCount ));
- i = wordCount;
+ wordDist = dist>>6;
+ if ( wordDist ) {
+ if ( 4 < wordDist ) wordDist = 4;
+ ptr = (uint64_t *) (aPtr + indexMultiwordLo( 4, wordDist ));
+ i = wordDist;
do {
wordJam = *ptr++;
if ( wordJam ) break;
@@ -91,32 +91,32 @@ void
} while ( i );
ptr = zPtr;
}
- if ( wordCount < 4 ) {
- aPtr += indexMultiwordHiBut( 4, wordCount );
- innerCount = count & 63;
- if ( innerCount ) {
+ if ( wordDist < 4 ) {
+ aPtr += indexMultiwordHiBut( 4, wordDist );
+ innerDist = dist & 63;
+ if ( innerDist ) {
softfloat_shortShiftRightJamM(
- 4 - wordCount,
+ 4 - wordDist,
aPtr,
- innerCount,
- zPtr + indexMultiwordLoBut( 4, wordCount )
+ innerDist,
+ zPtr + indexMultiwordLoBut( 4, wordDist )
);
- if ( ! wordCount ) goto wordJam;
+ if ( ! wordDist ) goto wordJam;
} else {
- aPtr += indexWordLo( 4 - wordCount );
+ aPtr += indexWordLo( 4 - wordDist );
ptr = zPtr + indexWordLo( 4 );
- for ( i = 4 - wordCount; i; --i ) {
+ for ( i = 4 - wordDist; i; --i ) {
*ptr = *aPtr;
aPtr += wordIncr;
ptr += wordIncr;
}
}
- ptr = zPtr + indexMultiwordHi( 4, wordCount );
+ ptr = zPtr + indexMultiwordHi( 4, wordDist );
}
do {
*ptr++ = 0;
- --wordCount;
- } while ( wordCount );
+ --wordDist;
+ } while ( wordDist );
wordJam:
if ( wordJam ) zPtr[indexWordLo( 4 )] |= 1;
diff --git a/source/s_shiftRightJam32.c b/source/s_shiftRightJam32.c
index e1df875..a413d1a 100644
--- a/source/s_shiftRightJam32.c
+++ b/source/s_shiftRightJam32.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,12 +39,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shiftRightJam32
-uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t count )
+uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
{
return
- (count < 31) ? a>>count | ((uint32_t) (a<<(-count & 31)) != 0)
- : (a != 0);
+ (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
}
diff --git a/source/s_shiftRightJam64.c b/source/s_shiftRightJam64.c
index 876640d..240d64f 100644
--- a/source/s_shiftRightJam64.c
+++ b/source/s_shiftRightJam64.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,12 +39,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shiftRightJam64
-uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t count )
+uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
{
return
- (count < 63) ? a>>count | ((uint64_t) (a<<(-count & 63)) != 0)
- : (a != 0);
+ (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
}
diff --git a/source/s_shiftRightJam64Extra.c b/source/s_shiftRightJam64Extra.c
index df31362..ff961b1 100644
--- a/source/s_shiftRightJam64Extra.c
+++ b/source/s_shiftRightJam64Extra.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,16 +42,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct uint64_extra
softfloat_shiftRightJam64Extra(
- uint64_t a, uint64_t extra, uint_fast32_t count )
+ uint64_t a, uint64_t extra, uint_fast32_t dist )
{
struct uint64_extra z;
- if ( count < 64 ) {
- z.v = a>>count;
- z.extra = a<<(-count & 63);
+ if ( dist < 64 ) {
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63);
} else {
z.v = 0;
- z.extra = (count == 64) ? a : (a != 0);
+ z.extra = (dist == 64) ? a : (a != 0);
}
z.extra |= (extra != 0);
return z;
diff --git a/source/s_shiftRightJamM.c b/source/s_shiftRightJamM.c
index 94e615f..0fc7bb1 100644
--- a/source/s_shiftRightJamM.c
+++ b/source/s_shiftRightJamM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -46,19 +46,19 @@ void
softfloat_shiftRightJamM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint32_t count,
+ uint32_t dist,
uint32_t *zPtr
)
{
- uint32_t wordJam, wordCount, *ptr;
- uint_fast8_t i, innerCount;
+ uint32_t wordJam, wordDist, *ptr;
+ uint_fast8_t i, innerDist;
wordJam = 0;
- wordCount = count>>5;
- if ( wordCount ) {
- if ( size_words < wordCount ) wordCount = size_words;
- ptr = (uint32_t *) (aPtr + indexMultiwordLo( size_words, wordCount ));
- i = wordCount;
+ wordDist = dist>>5;
+ if ( wordDist ) {
+ if ( size_words < wordDist ) wordDist = size_words;
+ ptr = (uint32_t *) (aPtr + indexMultiwordLo( size_words, wordDist ));
+ i = wordDist;
do {
wordJam = *ptr++;
if ( wordJam ) break;
@@ -66,32 +66,32 @@ void
} while ( i );
ptr = zPtr;
}
- if ( wordCount < size_words ) {
- aPtr += indexMultiwordHiBut( size_words, wordCount );
- innerCount = count & 31;
- if ( innerCount ) {
+ if ( wordDist < size_words ) {
+ aPtr += indexMultiwordHiBut( size_words, wordDist );
+ innerDist = dist & 31;
+ if ( innerDist ) {
softfloat_shortShiftRightJamM(
- size_words - wordCount,
+ size_words - wordDist,
aPtr,
- innerCount,
- zPtr + indexMultiwordLoBut( size_words, wordCount )
+ innerDist,
+ zPtr + indexMultiwordLoBut( size_words, wordDist )
);
- if ( ! wordCount ) goto wordJam;
+ if ( ! wordDist ) goto wordJam;
} else {
- aPtr += indexWordLo( size_words - wordCount );
+ aPtr += indexWordLo( size_words - wordDist );
ptr = zPtr + indexWordLo( size_words );
- for ( i = size_words - wordCount; i; --i ) {
+ for ( i = size_words - wordDist; i; --i ) {
*ptr = *aPtr;
aPtr += wordIncr;
ptr += wordIncr;
}
}
- ptr = zPtr + indexMultiwordHi( size_words, wordCount );
+ ptr = zPtr + indexMultiwordHi( size_words, wordDist );
}
do {
*ptr++ = 0;
- --wordCount;
- } while ( wordCount );
+ --wordDist;
+ } while ( wordDist );
wordJam:
if ( wordJam ) zPtr[indexWordLo( size_words )] |= 1;
diff --git a/source/s_shiftRightM.c b/source/s_shiftRightM.c
index cbea113..6256235 100644
--- a/source/s_shiftRightM.c
+++ b/source/s_shiftRightM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -46,44 +46,44 @@ void
softfloat_shiftRightM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint32_t count,
+ uint32_t dist,
uint32_t *zPtr
)
{
- uint32_t wordCount;
- uint_fast8_t innerCount;
+ uint32_t wordDist;
+ uint_fast8_t innerDist;
uint32_t *destPtr;
uint_fast8_t i;
- wordCount = count>>5;
- if ( wordCount < size_words ) {
- aPtr += indexMultiwordHiBut( size_words, wordCount );
- innerCount = count & 31;
- if ( innerCount ) {
+ wordDist = dist>>5;
+ if ( wordDist < size_words ) {
+ aPtr += indexMultiwordHiBut( size_words, wordDist );
+ innerDist = dist & 31;
+ if ( innerDist ) {
softfloat_shortShiftRightM(
- size_words - wordCount,
+ size_words - wordDist,
aPtr,
- innerCount,
- zPtr + indexMultiwordLoBut( size_words, wordCount )
+ innerDist,
+ zPtr + indexMultiwordLoBut( size_words, wordDist )
);
- if ( ! wordCount ) return;
+ if ( ! wordDist ) return;
} else {
- aPtr += indexWordLo( size_words - wordCount );
+ aPtr += indexWordLo( size_words - wordDist );
destPtr = zPtr + indexWordLo( size_words );
- for ( i = size_words - wordCount; i; --i ) {
+ for ( i = size_words - wordDist; i; --i ) {
*destPtr = *aPtr;
aPtr += wordIncr;
destPtr += wordIncr;
}
}
- zPtr += indexMultiwordHi( size_words, wordCount );
+ zPtr += indexMultiwordHi( size_words, wordDist );
} else {
- wordCount = size_words;
+ wordDist = size_words;
}
do {
*zPtr++ = 0;
- --wordCount;
- } while ( wordCount );
+ --wordDist;
+ } while ( wordDist );
}
diff --git a/source/s_shortShiftLeft128.c b/source/s_shortShiftLeft128.c
index 622ceb4..030c7b4 100644
--- a/source/s_shortShiftLeft128.c
+++ b/source/s_shortShiftLeft128.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -41,12 +41,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shortShiftLeft128
struct uint128
- softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t count )
+ softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
{
struct uint128 z;
- z.v64 = a64<<count | a0>>(-count & 63);
- z.v0 = a0<<count;
+ z.v64 = a64<<dist | a0>>(-dist & 63);
+ z.v0 = a0<<dist;
return z;
}
diff --git a/source/s_shortShiftLeft64To96M.c b/source/s_shortShiftLeft64To96M.c
index 0053913..9890705 100644
--- a/source/s_shortShiftLeft64To96M.c
+++ b/source/s_shortShiftLeft64To96M.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,11 +42,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
void
softfloat_shortShiftLeft64To96M(
- uint64_t a, uint_fast8_t count, uint32_t *zPtr )
+ uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
{
- zPtr[indexWord( 3, 0 )] = (uint32_t) a<<count;
- a >>= 32 - count;
+ zPtr[indexWord( 3, 0 )] = (uint32_t) a<<dist;
+ a >>= 32 - dist;
zPtr[indexWord( 3, 2 )] = a>>32;
zPtr[indexWord( 3, 1 )] = a;
diff --git a/source/s_shortShiftLeftM.c b/source/s_shortShiftLeftM.c
index acb3e29..701b1b0 100644
--- a/source/s_shortShiftLeftM.c
+++ b/source/s_shortShiftLeftM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -44,23 +44,23 @@ void
softfloat_shortShiftLeftM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint32_t *zPtr
)
{
- uint_fast8_t negCount;
+ uint_fast8_t uNegDist;
unsigned int index, lastIndex;
uint32_t partWordZ, wordA;
- negCount = -count;
+ uNegDist = -dist;
index = indexWordHi( size_words );
lastIndex = indexWordLo( size_words );
- partWordZ = aPtr[index]<<count;
+ partWordZ = aPtr[index]<<dist;
while ( index != lastIndex ) {
wordA = aPtr[index - wordIncr];
- zPtr[index] = partWordZ | wordA>>(negCount & 31);
+ zPtr[index] = partWordZ | wordA>>(uNegDist & 31);
index -= wordIncr;
- partWordZ = wordA<<count;
+ partWordZ = wordA<<dist;
}
zPtr[index] = partWordZ;
diff --git a/source/s_shortShiftRight128.c b/source/s_shortShiftRight128.c
index 4ccb301..352cebb 100644
--- a/source/s_shortShiftRight128.c
+++ b/source/s_shortShiftRight128.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -41,12 +41,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shortShiftRight128
struct uint128
- softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t count )
+ softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
{
struct uint128 z;
- z.v64 = a64>>count;
- z.v0 = a64<<(-count & 63) | a0>>count;
+ z.v64 = a64>>dist;
+ z.v0 = a64<<(-dist & 63) | a0>>dist;
return z;
}
diff --git a/source/s_shortShiftRightExtendM.c b/source/s_shortShiftRightExtendM.c
index 513bf02..e602331 100644
--- a/source/s_shortShiftRightExtendM.c
+++ b/source/s_shortShiftRightExtendM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -44,24 +44,24 @@ void
softfloat_shortShiftRightExtendM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint32_t *zPtr
)
{
- uint_fast8_t negCount;
+ uint_fast8_t uNegDist;
unsigned int indexA, lastIndexA;
uint32_t partWordZ, wordA;
- negCount = -count;
+ uNegDist = -dist;
indexA = indexWordLo( size_words );
lastIndexA = indexWordHi( size_words );
zPtr += indexWordLo( size_words + 1 );
partWordZ = 0;
for (;;) {
wordA = aPtr[indexA];
- *zPtr = wordA<<(negCount & 31) | partWordZ;
+ *zPtr = wordA<<(uNegDist & 31) | partWordZ;
zPtr += wordIncr;
- partWordZ = wordA>>count;
+ partWordZ = wordA>>dist;
if ( indexA == lastIndexA ) break;
indexA += wordIncr;
}
diff --git a/source/s_shortShiftRightJam128.c b/source/s_shortShiftRightJam128.c
index 7d1a3d8..777c41a 100644
--- a/source/s_shortShiftRightJam128.c
+++ b/source/s_shortShiftRightJam128.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,16 +42,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct uint128
softfloat_shortShiftRightJam128(
- uint64_t a64, uint64_t a0, uint_fast8_t count )
+ uint64_t a64, uint64_t a0, uint_fast8_t dist )
{
- int_fast8_t negCount;
+ uint_fast8_t uNegDist;
struct uint128 z;
- negCount = -count;
- z.v64 = a64>>count;
+ uNegDist = -dist;
+ z.v64 = a64>>dist;
z.v0 =
- a64<<(negCount & 63) | a0>>count
- | ((uint64_t) (a0<<(negCount & 63)) != 0);
+ a64<<(uNegDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(uNegDist & 63)) != 0);
return z;
}
diff --git a/source/s_shortShiftRightJam128Extra.c b/source/s_shortShiftRightJam128Extra.c
index 84cc2ae..32246e7 100644
--- a/source/s_shortShiftRightJam128Extra.c
+++ b/source/s_shortShiftRightJam128Extra.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,15 +42,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct uint128_extra
softfloat_shortShiftRightJam128Extra(
- uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t count )
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
{
- uint_fast8_t negCount;
+ uint_fast8_t uNegDist;
struct uint128_extra z;
- negCount = -count;
- z.v.v64 = a64>>count;
- z.v.v0 = a64<<(negCount & 63) | a0>>count;
- z.extra = a0<<(negCount & 63) | (extra != 0);
+ uNegDist = -dist;
+ z.v.v64 = a64>>dist;
+ z.v.v0 = a64<<(uNegDist & 63) | a0>>dist;
+ z.extra = a0<<(uNegDist & 63) | (extra != 0);
return z;
}
diff --git a/source/s_shortShiftRightJam64.c b/source/s_shortShiftRightJam64.c
index 93c6f0a..002581d 100644
--- a/source/s_shortShiftRightJam64.c
+++ b/source/s_shortShiftRightJam64.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -39,10 +39,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef softfloat_shortShiftRightJam64
-uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t count )
+uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
{
- return a>>count | ((a & (((uint_fast64_t) 1<<count) - 1)) != 0);
+ return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0);
}
diff --git a/source/s_shortShiftRightJam64Extra.c b/source/s_shortShiftRightJam64Extra.c
index 2ca4d01..4012bb7 100644
--- a/source/s_shortShiftRightJam64Extra.c
+++ b/source/s_shortShiftRightJam64Extra.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -42,12 +42,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct uint64_extra
softfloat_shortShiftRightJam64Extra(
- uint64_t a, uint64_t extra, uint_fast8_t count )
+ uint64_t a, uint64_t extra, uint_fast8_t dist )
{
struct uint64_extra z;
- z.v = a>>count;
- z.extra = a<<(-count & 63) | (extra != 0);
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63) | (extra != 0);
return z;
}
diff --git a/source/s_shortShiftRightJamM.c b/source/s_shortShiftRightJamM.c
index 9aeba80..38c9995 100644
--- a/source/s_shortShiftRightJamM.c
+++ b/source/s_shortShiftRightJamM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -44,25 +44,25 @@ void
softfloat_shortShiftRightJamM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint32_t *zPtr
)
{
- uint_fast8_t negCount;
+ uint_fast8_t uNegDist;
unsigned int index, lastIndex;
uint32_t partWordZ, wordA;
- negCount = -count;
+ uNegDist = -dist;
index = indexWordLo( size_words );
lastIndex = indexWordHi( size_words );
wordA = aPtr[index];
- partWordZ = wordA>>count;
- if ( partWordZ<<count != wordA ) partWordZ |= 1;
+ partWordZ = wordA>>dist;
+ if ( partWordZ<<dist != wordA ) partWordZ |= 1;
while ( index != lastIndex ) {
wordA = aPtr[index + wordIncr];
- zPtr[index] = wordA<<(negCount & 31) | partWordZ;
+ zPtr[index] = wordA<<(uNegDist & 31) | partWordZ;
index += wordIncr;
- partWordZ = wordA>>count;
+ partWordZ = wordA>>dist;
}
zPtr[index] = partWordZ;
diff --git a/source/s_shortShiftRightM.c b/source/s_shortShiftRightM.c
index ec61c25..4cfaa61 100644
--- a/source/s_shortShiftRightM.c
+++ b/source/s_shortShiftRightM.c
@@ -2,9 +2,9 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -44,23 +44,23 @@ void
softfloat_shortShiftRightM(
uint_fast8_t size_words,
const uint32_t *aPtr,
- uint_fast8_t count,
+ uint_fast8_t dist,
uint32_t *zPtr
)
{
- uint_fast8_t negCount;
+ uint_fast8_t uNegDist;
unsigned int index, lastIndex;
uint32_t partWordZ, wordA;
- negCount = -count;
+ uNegDist = -dist;
index = indexWordLo( size_words );
lastIndex = indexWordHi( size_words );
- partWordZ = aPtr[index]>>count;
+ partWordZ = aPtr[index]>>dist;
while ( index != lastIndex ) {
wordA = aPtr[index + wordIncr];
- zPtr[index] = wordA<<(negCount & 31) | partWordZ;
+ zPtr[index] = wordA<<(uNegDist & 31) | partWordZ;
index += wordIncr;
- partWordZ = wordA>>count;
+ partWordZ = wordA>>dist;
}
zPtr[index] = partWordZ;
diff --git a/source/s_sub128.c b/source/s_sub128.c
index 7659b40..00070db 100644
--- a/source/s_sub128.c
+++ b/source/s_sub128.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_sub1XM.c b/source/s_sub1XM.c
index d6104b4..6675076 100644
--- a/source/s_sub1XM.c
+++ b/source/s_sub1XM.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_sub256M.c b/source/s_sub256M.c
index c417eac..41c9922 100644
--- a/source/s_sub256M.c
+++ b/source/s_sub256M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_subM.c b/source/s_subM.c
index df984d0..7190715 100644
--- a/source/s_subM.c
+++ b/source/s_subM.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California. All rights reserved.
diff --git a/source/s_subMagsExtF80.c b/source/s_subMagsExtF80.c
index f1f0a19..253bb89 100644
--- a/source/s_subMagsExtF80.c
+++ b/source/s_subMagsExtF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -113,7 +113,7 @@ extFloat80_t
newlyAlignedBBigger:
expZ = expB;
bBigger:
- signZ ^= 1;
+ signZ = ! signZ;
sig128 = softfloat_sub128( sigB, 0, sigA, sigExtra );
goto normRoundPack;
/*------------------------------------------------------------------------
diff --git a/source/s_subMagsF128.c b/source/s_subMagsF128.c
index c0dfeeb..15c9709 100644
--- a/source/s_subMagsF128.c
+++ b/source/s_subMagsF128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -105,7 +105,7 @@ float128_t
expZ = expB;
sigB.v64 |= UINT64_C( 0x0010000000000000 );
bBigger:
- signZ ^= 1;
+ signZ = ! signZ;
sigZ = softfloat_sub128( sigB.v64, sigB.v0, sigA.v64, sigA.v0 );
goto normRoundPack;
expABigger:
diff --git a/source/s_subMagsF16.c b/source/s_subMagsF16.c
new file mode 100644
index 0000000..6aaf7aa
--- /dev/null
+++ b/source/s_subMagsF16.c
@@ -0,0 +1,182 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "specialize.h"
+#include "softfloat.h"
+
+float16_t softfloat_subMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ int_fast8_t expDiff;
+ uint_fast16_t uiZ;
+ int_fast16_t sigDiff;
+ bool signZ;
+ int_fast8_t shiftDist, expZ;
+ uint_fast16_t sigZ, sigX, sigY;
+ uint_fast32_t sig32Z;
+ int_fast8_t roundingMode;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF16UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ signZ = signF16UI( uiA );
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros16( sigDiff ) - 5;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = expA;
+ expZ = 0;
+ }
+ sigZ = sigDiff<<shiftDist;
+ goto pack;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF16UI( uiA );
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ signZ = ! signZ;
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ goto uiZ;
+ }
+ if ( expDiff <= -13 ) {
+ uiZ = packToF16UI( signZ, expB, sigB );
+ if ( expA | sigA ) goto subEpsilon;
+ goto uiZ;
+ }
+ expZ = expA + 19;
+ sigX = sigB | 0x0400;
+ sigY = sigA + (expA ? 0x0400 : sigA);
+ expDiff = -expDiff;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ uiZ = uiA;
+ if ( expA == 0x1F ) {
+ if ( sigA ) goto propagateNaN;
+ goto uiZ;
+ }
+ if ( 13 <= expDiff ) {
+ if ( expB | sigB ) goto subEpsilon;
+ goto uiZ;
+ }
+ expZ = expB + 19;
+ sigX = sigA | 0x0400;
+ sigY = sigB + (expB ? 0x0400 : sigB);
+ }
+ sig32Z = ((uint_fast32_t) sigX<<expDiff) - sigY;
+ shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
+ sig32Z <<= shiftDist;
+ expZ -= shiftDist;
+ sigZ = sig32Z>>16;
+ if ( sig32Z & 0xFFFF ) {
+ sigZ |= 1;
+ } else {
+ if ( ! (sigZ & 0xF) && ((unsigned int) expZ < 0x1E) ) {
+ sigZ >>= 4;
+ goto pack;
+ }
+ }
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ subEpsilon:
+ roundingMode = softfloat_roundingMode;
+ if ( roundingMode != softfloat_round_near_even ) {
+ if (
+ (roundingMode == softfloat_round_minMag)
+ || (roundingMode
+ == (signF16UI( uiZ ) ? softfloat_round_max
+ : softfloat_round_min))
+ ) {
+ --uiZ;
+ }
+ }
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ pack:
+ uiZ = packToF16UI( signZ, expZ, sigZ );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
diff --git a/source/s_subMagsF32.c b/source/s_subMagsF32.c
index ba5ac9a..012d4da 100644
--- a/source/s_subMagsF32.c
+++ b/source/s_subMagsF32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -41,8 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "specialize.h"
#include "softfloat.h"
-float32_t
- softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB, bool signZ )
+float32_t softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
{
int_fast16_t expA;
uint_fast32_t sigA;
@@ -50,61 +49,90 @@ float32_t
uint_fast32_t sigB;
int_fast16_t expDiff;
uint_fast32_t uiZ;
+ int_fast32_t sigDiff;
+ bool signZ;
+ int_fast8_t shiftDist;
int_fast16_t expZ;
- uint_fast32_t sigZ;
+ uint_fast32_t sigX, sigY;
union ui32_f32 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expA = expF32UI( uiA );
sigA = fracF32UI( uiA );
expB = expF32UI( uiB );
sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expDiff = expA - expB;
- sigA <<= 7;
- sigB <<= 7;
- if ( 0 < expDiff ) goto expABigger;
- if ( expDiff < 0 ) goto expBBigger;
- if ( expA == 0xFF ) {
- if ( sigA | sigB ) goto propagateNaN;
- softfloat_raiseFlags( softfloat_flag_invalid );
- uiZ = defaultNaNF32UI;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF32UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF32UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ signZ = signF32UI( uiA );
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros32( sigDiff ) - 8;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = expA;
+ expZ = 0;
+ }
+ uiZ = packToF32UI( signZ, expZ, sigDiff<<shiftDist );
goto uiZ;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF32UI( uiA );
+ sigA <<= 7;
+ sigB <<= 7;
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ signZ = ! signZ;
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF32UI( signZ, 0xFF, 0 );
+ goto uiZ;
+ }
+ expZ = expB - 1;
+ sigX = sigB | 0x40000000;
+ sigY = sigA + (expA ? 0x40000000 : sigA);
+ expDiff = -expDiff;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA - 1;
+ sigX = sigA | 0x40000000;
+ sigY = sigB + (expB ? 0x40000000 : sigB);
+ }
+ return
+ softfloat_normRoundPackToF32(
+ signZ, expZ, sigX - softfloat_shiftRightJam32( sigY, expDiff )
+ );
}
- if ( ! expA ) {
- expA = 1;
- expB = 1;
- }
- if ( sigB < sigA ) goto aBigger;
- if ( sigA < sigB ) goto bBigger;
- uiZ = packToF32UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
- goto uiZ;
- expBBigger:
- if ( expB == 0xFF ) {
- if ( sigB ) goto propagateNaN;
- uiZ = packToF32UI( signZ ^ 1, 0xFF, 0 );
- goto uiZ;
- }
- sigA += expA ? 0x40000000 : sigA;
- sigA = softfloat_shiftRightJam32( sigA, -expDiff );
- sigB |= 0x40000000;
- bBigger:
- signZ ^= 1;
- expZ = expB;
- sigZ = sigB - sigA;
- goto normRoundPack;
- expABigger:
- if ( expA == 0xFF ) {
- if ( sigA ) goto propagateNaN;
- uiZ = uiA;
- goto uiZ;
- }
- sigB += expB ? 0x40000000 : sigB;
- sigB = softfloat_shiftRightJam32( sigB, expDiff );
- sigA |= 0x40000000;
- aBigger:
- expZ = expA;
- sigZ = sigA - sigB;
- normRoundPack:
- return softfloat_normRoundPackToF32( signZ, expZ - 1, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
propagateNaN:
uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
uiZ:
diff --git a/source/s_subMagsF64.c b/source/s_subMagsF64.c
index e499d98..9c44368 100644
--- a/source/s_subMagsF64.c
+++ b/source/s_subMagsF64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All rights reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -50,61 +50,87 @@ float64_t
uint_fast64_t sigB;
int_fast16_t expDiff;
uint_fast64_t uiZ;
+ int_fast64_t sigDiff;
+ int_fast8_t shiftDist;
int_fast16_t expZ;
uint_fast64_t sigZ;
union ui64_f64 uZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expA = expF64UI( uiA );
sigA = fracF64UI( uiA );
expB = expF64UI( uiB );
sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
expDiff = expA - expB;
- sigA <<= 10;
- sigB <<= 10;
- if ( 0 < expDiff ) goto expABigger;
- if ( expDiff < 0 ) goto expBBigger;
- if ( expA == 0x7FF ) {
- if ( sigA | sigB ) goto propagateNaN;
- softfloat_raiseFlags( softfloat_flag_invalid );
- uiZ = defaultNaNF64UI;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF64UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = expA;
+ expZ = 0;
+ }
+ uiZ = packToF64UI( signZ, expZ, sigDiff<<shiftDist );
goto uiZ;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sigA <<= 10;
+ sigB <<= 10;
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ signZ = ! signZ;
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ goto uiZ;
+ }
+ sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
+ sigA = softfloat_shiftRightJam64( sigA, -expDiff );
+ sigB |= UINT64_C( 0x4000000000000000 );
+ expZ = expB;
+ sigZ = sigB - sigA;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
+ sigB = softfloat_shiftRightJam64( sigB, expDiff );
+ sigA |= UINT64_C( 0x4000000000000000 );
+ expZ = expA;
+ sigZ = sigA - sigB;
+ }
+ return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
}
- if ( ! expA ) {
- expA = 1;
- expB = 1;
- }
- if ( sigB < sigA ) goto aBigger;
- if ( sigA < sigB ) goto bBigger;
- uiZ = packToF64UI( softfloat_roundingMode == softfloat_round_min, 0, 0 );
- goto uiZ;
- expBBigger:
- if ( expB == 0x7FF ) {
- if ( sigB ) goto propagateNaN;
- uiZ = packToF64UI( signZ ^ 1, 0x7FF, 0 );
- goto uiZ;
- }
- sigA += expA ? UINT64_C( 0x4000000000000000 ) : sigA;
- sigA = softfloat_shiftRightJam64( sigA, -expDiff );
- sigB |= UINT64_C( 0x4000000000000000 );
- bBigger:
- signZ ^= 1;
- expZ = expB;
- sigZ = sigB - sigA;
- goto normRoundPack;
- expABigger:
- if ( expA == 0x7FF ) {
- if ( sigA ) goto propagateNaN;
- uiZ = uiA;
- goto uiZ;
- }
- sigB += expB ? UINT64_C( 0x4000000000000000 ) : sigB;
- sigB = softfloat_shiftRightJam64( sigB, expDiff );
- sigA |= UINT64_C( 0x4000000000000000 );
- aBigger:
- expZ = expA;
- sigZ = sigA - sigB;
- normRoundPack:
- return softfloat_normRoundPackToF64( signZ, expZ - 1, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
propagateNaN:
uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
uiZ:
diff --git a/source/s_tryPropagateNaNExtF80M.c b/source/s_tryPropagateNaNExtF80M.c
index 1cecd90..5d921f5 100644
--- a/source/s_tryPropagateNaNExtF80M.c
+++ b/source/s_tryPropagateNaNExtF80M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/s_tryPropagateNaNF128M.c b/source/s_tryPropagateNaNF128M.c
index 6125768..3e7c2fc 100644
--- a/source/s_tryPropagateNaNF128M.c
+++ b/source/s_tryPropagateNaNF128M.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All rights reserved.
diff --git a/source/softfloat_state.c b/source/softfloat_state.c
index d93087d..b61eb75 100644
--- a/source/softfloat_state.c
+++ b/source/softfloat_state.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -40,9 +40,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "specialize.h"
#include "softfloat.h"
-uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
-uint_fast8_t softfloat_detectTininess = init_detectTininess;
-uint_fast8_t softfloat_exceptionFlags = 0;
+#ifndef THREAD_LOCAL
+#define THREAD_LOCAL
+#endif
-uint_fast8_t extF80_roundingPrecision = 80;
+THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
+THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
+THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;
+
+THREAD_LOCAL uint_fast8_t extF80_roundingPrecision = 80;
diff --git a/source/ui32_to_extF80.c b/source/ui32_to_extF80.c
index 5039e9e..e08a18f 100644
--- a/source/ui32_to_extF80.c
+++ b/source/ui32_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,14 +42,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extFloat80_t ui32_to_extF80( uint32_t a )
{
uint_fast16_t uiZ64;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union { struct extFloat80M s; extFloat80_t f; } uZ;
uiZ64 = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros32( a );
- uiZ64 = 0x401E - shiftCount;
- a <<= shiftCount;
+ shiftDist = softfloat_countLeadingZeros32( a );
+ uiZ64 = 0x401E - shiftDist;
+ a <<= shiftDist;
}
uZ.s.signExp = uiZ64;
uZ.s.signif = (uint_fast64_t) a<<32;
diff --git a/source/ui32_to_extF80M.c b/source/ui32_to_extF80M.c
index 8d475f7..f824d00 100644
--- a/source/ui32_to_extF80M.c
+++ b/source/ui32_to_extF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -55,15 +55,15 @@ void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
struct extFloat80M *zSPtr;
uint_fast16_t uiZ64;
uint64_t sigZ;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
zSPtr = (struct extFloat80M *) zPtr;
uiZ64 = 0;
sigZ = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros32( a );
- uiZ64 = packToExtF80UI64( 0, 0x401E - shiftCount );
- sigZ = (uint64_t) (a<<shiftCount)<<32;
+ shiftDist = softfloat_countLeadingZeros32( a );
+ uiZ64 = packToExtF80UI64( 0, 0x401E - shiftDist );
+ sigZ = (uint64_t) (a<<shiftDist)<<32;
}
zSPtr->signExp = uiZ64;
zSPtr->signif = sigZ;
diff --git a/source/ui32_to_f128.c b/source/ui32_to_f128.c
index 366376b..21efd03 100644
--- a/source/ui32_to_f128.c
+++ b/source/ui32_to_f128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,15 +42,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
float128_t ui32_to_f128( uint32_t a )
{
uint_fast64_t uiZ64;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui128_f128 uZ;
uiZ64 = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros32( a ) + 17;
+ shiftDist = softfloat_countLeadingZeros32( a ) + 17;
uiZ64 =
packToF128UI64(
- 0, 0x402E - shiftCount, (uint_fast64_t) a<<shiftCount );
+ 0, 0x402E - shiftDist, (uint_fast64_t) a<<shiftDist );
}
uZ.ui.v64 = uiZ64;
uZ.ui.v0 = 0;
diff --git a/source/ui32_to_f128M.c b/source/ui32_to_f128M.c
index e7ffdfb..62095f2 100644
--- a/source/ui32_to_f128M.c
+++ b/source/ui32_to_f128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -53,16 +53,16 @@ void ui32_to_f128M( uint32_t a, float128_t *zPtr )
void ui32_to_f128M( uint32_t a, float128_t *zPtr )
{
uint32_t *zWPtr, uiZ96, uiZ64;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
uint64_t normA;
zWPtr = (uint32_t *) zPtr;
uiZ96 = 0;
uiZ64 = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros32( a ) + 17;
- normA = (uint64_t) a<<shiftCount;
- uiZ96 = packToF128UI96( 0, 0x402E - shiftCount, normA>>32 );
+ shiftDist = softfloat_countLeadingZeros32( a ) + 17;
+ normA = (uint64_t) a<<shiftDist;
+ uiZ96 = packToF128UI96( 0, 0x402E - shiftDist, normA>>32 );
uiZ64 = normA;
}
zWPtr[indexWord( 4, 3 )] = uiZ96;
diff --git a/source/ui32_to_f16.c b/source/ui32_to_f16.c
new file mode 100644
index 0000000..a2f7485
--- /dev/null
+++ b/source/ui32_to_f16.c
@@ -0,0 +1,65 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t ui32_to_f16( uint32_t a )
+{
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ shiftDist = softfloat_countLeadingZeros32( a ) - 21;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
+ : 0;
+ return u.f;
+ } else {
+ shiftDist += 4;
+ sig =
+ (shiftDist < 0)
+ ? a>>(-shiftDist) | ((uint32_t) (a<<(shiftDist & 31)) != 0)
+ : (uint_fast16_t) a<<shiftDist;
+ return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
+ }
+
+}
+
diff --git a/source/ui32_to_f32.c b/source/ui32_to_f32.c
index ae98fb7..4717de9 100644
--- a/source/ui32_to_f32.c
+++ b/source/ui32_to_f32.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All Rights Reserved.
diff --git a/source/ui32_to_f64.c b/source/ui32_to_f64.c
index 6b72fa5..a6a0439 100644
--- a/source/ui32_to_f64.c
+++ b/source/ui32_to_f64.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,16 +42,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
float64_t ui32_to_f64( uint32_t a )
{
uint_fast64_t uiZ;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui64_f64 uZ;
if ( ! a ) {
uiZ = 0;
} else {
- shiftCount = softfloat_countLeadingZeros32( a ) + 21;
+ shiftDist = softfloat_countLeadingZeros32( a ) + 21;
uiZ =
- packToF64UI(
- 0, 0x432 - shiftCount, (uint_fast64_t) a<<shiftCount );
+ packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<<shiftDist );
}
uZ.ui = uiZ;
return uZ.f;
diff --git a/source/ui64_to_extF80.c b/source/ui64_to_extF80.c
index a8be984..b92b53e 100644
--- a/source/ui64_to_extF80.c
+++ b/source/ui64_to_extF80.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,14 +42,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
extFloat80_t ui64_to_extF80( uint64_t a )
{
uint_fast16_t uiZ64;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union { struct extFloat80M s; extFloat80_t f; } uZ;
uiZ64 = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros64( a );
- uiZ64 = 0x403E - shiftCount;
- a <<= shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( a );
+ uiZ64 = 0x403E - shiftDist;
+ a <<= shiftDist;
}
uZ.s.signExp = uiZ64;
uZ.s.signif = a;
diff --git a/source/ui64_to_extF80M.c b/source/ui64_to_extF80M.c
index 2cf8419..c2c59b0 100644
--- a/source/ui64_to_extF80M.c
+++ b/source/ui64_to_extF80M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -55,15 +55,15 @@ void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
struct extFloat80M *zSPtr;
uint_fast16_t uiZ64;
uint64_t sigZ;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
zSPtr = (struct extFloat80M *) zPtr;
uiZ64 = 0;
sigZ = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros64( a );
- uiZ64 = packToExtF80UI64( 0, 0x403E - shiftCount );
- sigZ = a<<shiftCount;
+ shiftDist = softfloat_countLeadingZeros64( a );
+ uiZ64 = packToExtF80UI64( 0, 0x403E - shiftDist );
+ sigZ = a<<shiftDist;
}
zSPtr->signExp = uiZ64;
zSPtr->signif = sigZ;
diff --git a/source/ui64_to_f128.c b/source/ui64_to_f128.c
index 806b16a..25afc29 100644
--- a/source/ui64_to_f128.c
+++ b/source/ui64_to_f128.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -42,7 +42,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
float128_t ui64_to_f128( uint64_t a )
{
uint_fast64_t uiZ64, uiZ0;
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
struct uint128 zSig;
union ui128_f128 uZ;
@@ -50,14 +50,14 @@ float128_t ui64_to_f128( uint64_t a )
uiZ64 = 0;
uiZ0 = 0;
} else {
- shiftCount = softfloat_countLeadingZeros64( a ) + 49;
- if ( 64 <= shiftCount ) {
- zSig.v64 = a<<(shiftCount - 64);
+ shiftDist = softfloat_countLeadingZeros64( a ) + 49;
+ if ( 64 <= shiftDist ) {
+ zSig.v64 = a<<(shiftDist - 64);
zSig.v0 = 0;
} else {
- zSig = softfloat_shortShiftLeft128( 0, a, shiftCount );
+ zSig = softfloat_shortShiftLeft128( 0, a, shiftDist );
}
- uiZ64 = packToF128UI64( 0, 0x406E - shiftCount, zSig.v64 );
+ uiZ64 = packToF128UI64( 0, 0x406E - shiftDist, zSig.v64 );
uiZ0 = zSig.v0;
}
uZ.ui.v64 = uiZ64;
diff --git a/source/ui64_to_f128M.c b/source/ui64_to_f128M.c
index b6e0287..eecf040 100644
--- a/source/ui64_to_f128M.c
+++ b/source/ui64_to_f128M.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -53,7 +53,7 @@ void ui64_to_f128M( uint64_t a, float128_t *zPtr )
void ui64_to_f128M( uint64_t a, float128_t *zPtr )
{
uint32_t *zWPtr, uiZ96, uiZ64;
- uint_fast8_t shiftCount;
+ uint_fast8_t shiftDist;
uint32_t *ptr;
zWPtr = (uint32_t *) zPtr;
@@ -62,20 +62,19 @@ void ui64_to_f128M( uint64_t a, float128_t *zPtr )
zWPtr[indexWord( 4, 1 )] = 0;
zWPtr[indexWord( 4, 0 )] = 0;
if ( a ) {
- shiftCount = softfloat_countLeadingZeros64( a ) + 17;
- if ( shiftCount < 32 ) {
+ shiftDist = softfloat_countLeadingZeros64( a ) + 17;
+ if ( shiftDist < 32 ) {
ptr = zWPtr + indexMultiwordHi( 4, 3 );
ptr[indexWord( 3, 2 )] = 0;
ptr[indexWord( 3, 1 )] = a>>32;
ptr[indexWord( 3, 0 )] = a;
- softfloat_shortShiftLeft96M( ptr, shiftCount, ptr );
+ softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
ptr[indexWordHi( 3 )] =
- packToF128UI96(
- 0, 0x404E - shiftCount, ptr[indexWordHi( 3 )] );
+ packToF128UI96( 0, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
return;
}
- a <<= shiftCount - 32;
- uiZ96 = packToF128UI96( 0, 0x404E - shiftCount, a>>32 );
+ a <<= shiftDist - 32;
+ uiZ96 = packToF128UI96( 0, 0x404E - shiftDist, a>>32 );
uiZ64 = a;
}
zWPtr[indexWord( 4, 3 )] = uiZ96;
diff --git a/source/ui64_to_f16.c b/source/ui64_to_f16.c
new file mode 100644
index 0000000..f9ba0a8
--- /dev/null
+++ b/source/ui64_to_f16.c
@@ -0,0 +1,64 @@
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3b, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include <stdint.h>
+#include "platform.h"
+#include "internals.h"
+#include "softfloat.h"
+
+float16_t ui64_to_f16( uint64_t a )
+{
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ shiftDist = softfloat_countLeadingZeros64( a ) - 53;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ 0, 0x18 - shiftDist, (uint_fast16_t) a<<shiftDist )
+ : 0;
+ return u.f;
+ } else {
+ shiftDist += 4;
+ sig =
+ (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
+ : (uint_fast16_t) a<<shiftDist;
+ return softfloat_roundPackToF16( 0, 0x1C - shiftDist, sig );
+ }
+
+}
+
diff --git a/source/ui64_to_f32.c b/source/ui64_to_f32.c
index d67c6f9..cf175fe 100644
--- a/source/ui64_to_f32.c
+++ b/source/ui64_to_f32.c
@@ -2,10 +2,10 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
-Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
-All Rights Reserved.
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -41,23 +41,23 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
float32_t ui64_to_f32( uint64_t a )
{
- int_fast8_t shiftCount;
+ int_fast8_t shiftDist;
union ui32_f32 u;
uint_fast32_t sig;
- shiftCount = softfloat_countLeadingZeros64( a ) - 40;
- if ( 0 <= shiftCount ) {
+ shiftDist = softfloat_countLeadingZeros64( a ) - 40;
+ if ( 0 <= shiftDist ) {
u.ui =
a ? packToF32UI(
- 0, 0x95 - shiftCount, (uint_fast32_t) a<<shiftCount )
+ 0, 0x95 - shiftDist, (uint_fast32_t) a<<shiftDist )
: 0;
return u.f;
} else {
- shiftCount += 7;
+ shiftDist += 7;
sig =
- (shiftCount < 0) ? softfloat_shortShiftRightJam64( a, -shiftCount )
- : (uint_fast32_t) a<<shiftCount;
- return softfloat_roundPackToF32( 0, 0x9C - shiftCount, sig );
+ (shiftDist < 0) ? softfloat_shortShiftRightJam64( a, -shiftDist )
+ : (uint_fast32_t) a<<shiftDist;
+ return softfloat_roundPackToF32( 0, 0x9C - shiftDist, sig );
}
}
diff --git a/source/ui64_to_f64.c b/source/ui64_to_f64.c
index fcaa682..c475e13 100644
--- a/source/ui64_to_f64.c
+++ b/source/ui64_to_f64.c
@@ -2,7 +2,7 @@
/*============================================================================
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
-Package, Release 3a, by John R. Hauser.
+Package, Release 3b, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
All Rights Reserved.