Skip to content

Commit 59c058e

Browse files
rename Default(Ignore|Signal)ExactUnderflow removing Default
1 parent 4c20f71 commit 59c058e

5 files changed

+2086
-2085
lines changed

make_from_real_algebraic_number_test_cases.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function write_test_cases() {
7474
local flag_overflow="${output[6]}"
7575
local flag_infinite="${output[7]}"
7676
local flag_invalid="${output[8]}"
77-
if [[ "$exception_handling_mode" != "DefaultIgnoreExactUnderflow" ]] && ((mantissa != 0 && !gt_min_normal && !le_neg_min_normal)); then
77+
if [[ "$exception_handling_mode" != "IgnoreExactUnderflow" ]] && ((mantissa != 0 && !gt_min_normal && !le_neg_min_normal)); then
7878
((flags |= flag_underflow))
7979
fi
8080
local decoded_flags=()
@@ -104,7 +104,7 @@ exec > "test_data/from_real_algebraic_number.txt"
104104
for rounding_mode in TiesToEven TowardZero TowardNegative TowardPositive TiesToAway; do
105105
lc_rounding_mode="`echo "$rounding_mode" | sed 's/\([^A-Z]\)\([A-Z]\)/\1_\2/g; s/.*/\L&/'`"
106106
for tininess_detection_mode in BeforeRounding AfterRounding; do
107-
for exception_handling_mode in DefaultIgnoreExactUnderflow DefaultSignalExactUnderflow; do
107+
for exception_handling_mode in IgnoreExactUnderflow SignalExactUnderflow; do
108108
echo "# test the values right around zero for $rounding_mode $exception_handling_mode $tininess_detection_mode"
109109
write_test_cases -0x20 0x20 0x4 -28 $rounding_mode $exception_handling_mode $tininess_detection_mode
110110
echo
@@ -116,16 +116,16 @@ for rounding_mode in TiesToEven TowardZero TowardNegative TowardPositive TiesToA
116116
done
117117
done
118118
echo "# test the values right around 1 and -1 for $rounding_mode"
119-
write_test_cases -0x4020 -0x3FE0 0x4 -14 $rounding_mode DefaultIgnoreExactUnderflow BeforeRounding
120-
write_test_cases 0x3FE0 0x4020 0x4 -14 $rounding_mode DefaultIgnoreExactUnderflow BeforeRounding
119+
write_test_cases -0x4020 -0x3FE0 0x4 -14 $rounding_mode IgnoreExactUnderflow BeforeRounding
120+
write_test_cases 0x3FE0 0x4020 0x4 -14 $rounding_mode IgnoreExactUnderflow BeforeRounding
121121
echo
122122
echo "# test the values right around max normal for $rounding_mode"
123-
write_test_cases -0x4010 -0x3FF0 0x2 2 $rounding_mode DefaultIgnoreExactUnderflow BeforeRounding
124-
write_test_cases 0x3FF0 0x4010 0x2 2 $rounding_mode DefaultIgnoreExactUnderflow BeforeRounding
123+
write_test_cases -0x4010 -0x3FF0 0x2 2 $rounding_mode IgnoreExactUnderflow BeforeRounding
124+
write_test_cases 0x3FF0 0x4010 0x2 2 $rounding_mode IgnoreExactUnderflow BeforeRounding
125125
echo
126126
echo "# test the values much larger than max normal for $rounding_mode"
127-
write_test_cases -1 -1 1 20 $rounding_mode DefaultIgnoreExactUnderflow BeforeRounding
128-
write_test_cases 1 1 1 20 $rounding_mode DefaultIgnoreExactUnderflow BeforeRounding
127+
write_test_cases -1 -1 1 20 $rounding_mode IgnoreExactUnderflow BeforeRounding
128+
write_test_cases 1 1 1 20 $rounding_mode IgnoreExactUnderflow BeforeRounding
129129
echo
130130
done
131131
echo >&2

src/lib.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,21 @@ python_enum! {
198198
/// to emulate flush-to-zero FP semantics.
199199
///
200200
/// Since simple-soft-float doesn't support trapping exceptions, to simulate
201-
/// trapping exceptions, use `DefaultSignalExactUnderflow` as the exception
201+
/// trapping exceptions, use `SignalExactUnderflow` as the exception
202202
/// handling mode and check `status_flags` after every operation.
203203
///
204-
/// Otherwise, use the default value of `DefaultIgnoreExactUnderflow`.
204+
/// Otherwise, use the default value of `IgnoreExactUnderflow`.
205205
pub enum ExceptionHandlingMode {
206-
DefaultIgnoreExactUnderflow,
207-
DefaultSignalExactUnderflow,
206+
/// Use the default behavior of ignoring exact underflow.
207+
IgnoreExactUnderflow,
208+
/// Signal the `UNDERFLOW` exception even if the results are exact.
209+
SignalExactUnderflow,
208210
}
209211
}
210212

211213
impl Default for ExceptionHandlingMode {
212214
fn default() -> ExceptionHandlingMode {
213-
ExceptionHandlingMode::DefaultIgnoreExactUnderflow
215+
ExceptionHandlingMode::IgnoreExactUnderflow
214216
}
215217
}
216218

@@ -2222,8 +2224,8 @@ impl<Bits: FloatBitsType, FT: FloatTraits<Bits = Bits>> Float<FT> {
22222224
&max_mantissa,
22232225
);
22242226
let check_for_underflow = match fp_state.exception_handling_mode {
2225-
ExceptionHandlingMode::DefaultIgnoreExactUnderflow => inexact,
2226-
ExceptionHandlingMode::DefaultSignalExactUnderflow => true,
2227+
ExceptionHandlingMode::IgnoreExactUnderflow => inexact,
2228+
ExceptionHandlingMode::SignalExactUnderflow => true,
22272229
};
22282230
if exponent < exponent_min && check_for_underflow {
22292231
let tiny = match fp_state.tininess_detection_mode {

src/test_cases.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ impl_test_case_argument_for_enum! {
251251

252252
impl_test_case_argument_for_enum! {
253253
enum ExceptionHandlingMode {
254-
DefaultIgnoreExactUnderflow,
255-
DefaultSignalExactUnderflow,
254+
IgnoreExactUnderflow,
255+
SignalExactUnderflow,
256256
}
257257
}
258258

@@ -551,7 +551,7 @@ test_case! {
551551
#[output] result: F16,
552552
#[output] status_flags: StatusFlags,
553553
) {
554-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
554+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
555555
let mut fp_state = FPState {
556556
rounding_mode,
557557
exception_handling_mode,
@@ -572,7 +572,7 @@ test_case! {
572572
#[output] result: F16,
573573
#[output] status_flags: StatusFlags,
574574
) {
575-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
575+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
576576
let mut fp_state = FPState {
577577
rounding_mode,
578578
exception_handling_mode,
@@ -593,7 +593,7 @@ test_case! {
593593
#[output] result: F16,
594594
#[output] status_flags: StatusFlags,
595595
) {
596-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
596+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
597597
let mut fp_state = FPState {
598598
rounding_mode,
599599
exception_handling_mode,
@@ -614,7 +614,7 @@ test_case! {
614614
#[output] result: F16,
615615
#[output] status_flags: StatusFlags,
616616
) {
617-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
617+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
618618
let mut fp_state = FPState {
619619
rounding_mode,
620620
exception_handling_mode,
@@ -635,7 +635,7 @@ test_case! {
635635
#[output] result: F16,
636636
#[output] status_flags: StatusFlags,
637637
) {
638-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
638+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
639639
let mut fp_state = FPState {
640640
rounding_mode,
641641
exception_handling_mode,
@@ -656,7 +656,7 @@ fn mul_add_test_case(
656656
result: &mut F16,
657657
status_flags: &mut StatusFlags,
658658
) {
659-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
659+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
660660
let mut fp_state = FPState {
661661
rounding_mode,
662662
exception_handling_mode,
@@ -785,7 +785,7 @@ test_case! {
785785
#[output] result: F16,
786786
#[output] status_flags: StatusFlags,
787787
) {
788-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
788+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
789789
let mut fp_state = FPState {
790790
rounding_mode,
791791
exception_handling_mode,
@@ -805,7 +805,7 @@ test_case! {
805805
#[output] result: F16,
806806
#[output] status_flags: StatusFlags,
807807
) {
808-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
808+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
809809
let mut fp_state = FPState {
810810
rounding_mode,
811811
exception_handling_mode,
@@ -844,7 +844,7 @@ test_case! {
844844
#[output] result: F16,
845845
#[output] status_flags: StatusFlags,
846846
) {
847-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
847+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
848848
let mut fp_state = FPState {
849849
rounding_mode,
850850
exception_handling_mode,
@@ -864,7 +864,7 @@ test_case! {
864864
#[output] result: F16,
865865
#[output] status_flags: StatusFlags,
866866
) {
867-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
867+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
868868
let mut fp_state = FPState {
869869
rounding_mode,
870870
exception_handling_mode,
@@ -884,7 +884,7 @@ test_case! {
884884
#[output] result: F32,
885885
#[output] status_flags: StatusFlags,
886886
) {
887-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
887+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
888888
let mut fp_state = FPState {
889889
rounding_mode,
890890
exception_handling_mode,
@@ -904,7 +904,7 @@ test_case! {
904904
#[output] result: F16,
905905
#[output] status_flags: StatusFlags,
906906
) {
907-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
907+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
908908
let mut fp_state = FPState {
909909
rounding_mode,
910910
exception_handling_mode,
@@ -1005,7 +1005,7 @@ test_case! {
10051005
#[output] result: F16,
10061006
#[output] status_flags: StatusFlags,
10071007
) {
1008-
let exception_handling_mode = ExceptionHandlingMode::DefaultIgnoreExactUnderflow;
1008+
let exception_handling_mode = ExceptionHandlingMode::IgnoreExactUnderflow;
10091009
let mut fp_state = FPState {
10101010
rounding_mode,
10111011
exception_handling_mode,

0 commit comments

Comments
 (0)