@@ -61,7 +61,9 @@ python_enum! {
61
61
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_sign_enum) ]
62
62
/// sign of floating-point number
63
63
pub enum Sign {
64
+ /// + sign
64
65
Positive = 0 ,
66
+ /// - sign
65
67
Negative = 1 ,
66
68
}
67
69
}
@@ -167,6 +169,7 @@ impl Default for RoundingMode {
167
169
}
168
170
169
171
bitflags ! {
172
+ /// IEEE 754 status flags
170
173
pub struct StatusFlags : u32 {
171
174
const INVALID_OPERATION = 0b00001 ;
172
175
const DIVISION_BY_ZERO = 0b00010 ;
@@ -184,6 +187,21 @@ impl Default for StatusFlags {
184
187
185
188
python_enum ! {
186
189
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_exception_handling_mode_enum) ]
190
+ /// Select if the underflow exception should be signaled when the result is exact.
191
+ ///
192
+ /// In IEEE 754, when exceptions are set to use the default handlers
193
+ /// (they are ignored -- the default for most programming languages), then
194
+ /// underflow exceptions are only signalled when the result is not exact.
195
+ ///
196
+ /// When exceptions are instead set to trap, then underflow exceptions are
197
+ /// signalled even when the result is exact, to allow the exception handler
198
+ /// to emulate flush-to-zero FP semantics.
199
+ ///
200
+ /// Since simple-soft-float doesn't support trapping exceptions, to simulate
201
+ /// trapping exceptions, use `DefaultSignalExactUnderflow` as the exception
202
+ /// handling mode and check `status_flags` after every operation.
203
+ ///
204
+ /// Otherwise, use the default value of `DefaultIgnoreExactUnderflow`.
187
205
pub enum ExceptionHandlingMode {
188
206
DefaultIgnoreExactUnderflow ,
189
207
DefaultSignalExactUnderflow ,
@@ -198,6 +216,7 @@ impl Default for ExceptionHandlingMode {
198
216
199
217
python_enum ! {
200
218
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_tininess_detection_mode_enum) ]
219
+ /// IEEE 754 tininess detection mode
201
220
pub enum TininessDetectionMode {
202
221
AfterRounding ,
203
222
BeforeRounding ,
@@ -212,6 +231,7 @@ impl Default for TininessDetectionMode {
212
231
213
232
python_enum ! {
214
233
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_binary_nan_propagation_mode_enum) ]
234
+ /// Select how NaN payloads should be propagated
215
235
pub enum BinaryNaNPropagationMode {
216
236
AlwaysCanonical ,
217
237
FirstSecond ,
@@ -223,6 +243,7 @@ python_enum! {
223
243
224
244
python_enum ! {
225
245
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_unary_nan_propagation_mode_enum) ]
246
+ /// Select how NaN payloads should be propagated
226
247
pub enum UnaryNaNPropagationMode {
227
248
AlwaysCanonical ,
228
249
First ,
@@ -377,6 +398,7 @@ impl Default for TernaryNaNPropagationResults {
377
398
378
399
python_enum ! {
379
400
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_ternary_nan_propagation_mode_enum) ]
401
+ /// Select how NaN payloads should be propagated
380
402
pub enum TernaryNaNPropagationMode {
381
403
AlwaysCanonical ,
382
404
FirstSecondThird ,
@@ -586,6 +608,7 @@ impl TernaryNaNPropagationMode {
586
608
587
609
python_enum ! {
588
610
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_fma_inf_zero_qnan_result_enum) ]
611
+ /// select the result of fused `Infinity * 0.0 + QNaN` and `0.0 * Infinity + QNaN`
589
612
pub enum FMAInfZeroQNaNResult {
590
613
FollowNaNPropagationMode ,
591
614
CanonicalAndGenerateInvalid ,
@@ -601,6 +624,7 @@ impl Default for FMAInfZeroQNaNResult {
601
624
602
625
python_enum ! {
603
626
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_float_to_float_conversion_nan_propagation_mode_enum) ]
627
+ /// select how NaN payloads are propagated in float -> float conversions
604
628
pub enum FloatToFloatConversionNaNPropagationMode {
605
629
AlwaysCanonical ,
606
630
RetainMostSignificantBits ,
@@ -636,6 +660,7 @@ impl From<FPStateMergeFailed> for PyErr {
636
660
}
637
661
638
662
impl FPState {
663
+ /// combine two `FPState` values into one, assigning the result to `self`
639
664
pub fn checked_merge_assign ( & mut self , rhs : Self ) -> Result < ( ) , FPStateMergeFailed > {
640
665
let status_flags = self . status_flags | rhs. status_flags ;
641
666
let same = Self {
@@ -652,13 +677,16 @@ impl FPState {
652
677
Err ( FPStateMergeFailed )
653
678
}
654
679
}
680
+ /// combine two `FPState` values into one, assigning the result to `self`
655
681
pub fn merge_assign ( & mut self , rhs : Self ) {
656
682
self . checked_merge_assign ( rhs) . unwrap ( ) ;
657
683
}
684
+ /// combine two `FPState` values into one, returning the result
658
685
pub fn checked_merge ( mut self , rhs : Self ) -> Result < Self , FPStateMergeFailed > {
659
686
self . checked_merge_assign ( rhs) ?;
660
687
Ok ( self )
661
688
}
689
+ /// combine two `FPState` values into one, returning the result
662
690
pub fn merge ( mut self , rhs : Self ) -> Self {
663
691
self . merge_assign ( rhs) ;
664
692
self
@@ -667,6 +695,7 @@ impl FPState {
667
695
668
696
python_enum ! {
669
697
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_float_class_enum) ]
698
+ /// float classification
670
699
pub enum FloatClass {
671
700
NegativeInfinity ,
672
701
NegativeNormal ,
@@ -816,6 +845,12 @@ impl Neg for FloatClass {
816
845
817
846
python_enum ! {
818
847
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_quiet_nan_format_enum) ]
848
+ /// the format for quiet NaN values
849
+ ///
850
+ /// IEEE 754 states that implementations *should* use the MSB of the
851
+ /// mantissa being set to indicate a quiet NaN, however MIPS before
852
+ /// the 2008 revision and PA-RISC use the MSB of the mantissa being clear
853
+ /// to indicate a quiet NaN.
819
854
pub enum QuietNaNFormat {
820
855
/// MSB of mantissa set to indicate quiet NaN
821
856
Standard ,
@@ -1611,6 +1646,7 @@ impl RoundedMantissa {
1611
1646
1612
1647
python_enum ! {
1613
1648
#[ pyenum( module = simple_soft_float, repr = u8 , test_fn = test_up_or_down_enum) ]
1649
+ /// select Up or Down
1614
1650
pub enum UpOrDown {
1615
1651
Up ,
1616
1652
Down ,
0 commit comments