File tree 3 files changed +8
-4
lines changed
3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ impl Float for f8 {
30
30
const INFINITY : Self = Self ( 0b0_1111_000 ) ;
31
31
const NEG_INFINITY : Self = Self ( 0b1_1111_000 ) ;
32
32
const NAN : Self = Self ( 0b0_1111_100 ) ;
33
+ // FIXME: incorrect values
34
+ const EPSILON : Self = Self :: ZERO ;
33
35
const PI : Self = Self :: ZERO ;
34
36
const NEG_PI : Self = Self :: ZERO ;
35
37
const FRAC_PI_2 : Self = Self :: ZERO ;
Original file line number Diff line number Diff line change 96
96
ix = scaled. to_bits ( ) ;
97
97
match top {
98
98
Exp :: Shifted ( ref mut v) => {
99
- * v = scaled. exp ( ) . unsigned ( ) ;
99
+ * v = scaled. exp ( ) ;
100
100
* v = ( * v) . wrapping_sub ( F :: SIG_BITS ) ;
101
101
}
102
102
Exp :: NoShift ( ( ) ) => {
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ pub trait Float:
34
34
const NAN : Self ;
35
35
const MAX : Self ;
36
36
const MIN : Self ;
37
+ const EPSILON : Self ;
37
38
const PI : Self ;
38
39
const NEG_PI : Self ;
39
40
const FRAC_PI_2 : Self ;
@@ -107,13 +108,13 @@ pub trait Float:
107
108
}
108
109
109
110
/// Returns the exponent, not adjusting for bias, not accounting for subnormals or zero.
110
- fn exp ( self ) -> i32 {
111
- ( u32:: cast_from ( self . to_bits ( ) >> Self :: SIG_BITS ) & Self :: EXP_MAX ) . signed ( )
111
+ fn exp ( self ) -> u32 {
112
+ u32:: cast_from ( self . to_bits ( ) >> Self :: SIG_BITS ) & Self :: EXP_MAX
112
113
}
113
114
114
115
/// Extract the exponent and adjust it for bias, not accounting for subnormals or zero.
115
116
fn exp_unbiased ( self ) -> i32 {
116
- self . exp ( ) - ( Self :: EXP_BIAS as i32 )
117
+ self . exp ( ) . signed ( ) - ( Self :: EXP_BIAS as i32 )
117
118
}
118
119
119
120
/// Returns the significand with no implicit bit (or the "fractional" part)
@@ -180,6 +181,7 @@ macro_rules! float_impl {
180
181
const MAX : Self = -Self :: MIN ;
181
182
// Sign bit set, saturated mantissa, saturated exponent with last bit zeroed
182
183
const MIN : Self = $from_bits( Self :: Int :: MAX & !( 1 << Self :: SIG_BITS ) ) ;
184
+ const EPSILON : Self = <$ty>:: EPSILON ;
183
185
184
186
const PI : Self = core:: $ty:: consts:: PI ;
185
187
const NEG_PI : Self = -Self :: PI ;
You can’t perform that action at this time.
0 commit comments