This repository was archived by the owner on Apr 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Expand file tree Collapse file tree 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 {
3030 const INFINITY : Self = Self ( 0b0_1111_000 ) ;
3131 const NEG_INFINITY : Self = Self ( 0b1_1111_000 ) ;
3232 const NAN : Self = Self ( 0b0_1111_100 ) ;
33+ // FIXME: incorrect values
34+ const EPSILON : Self = Self :: ZERO ;
3335 const PI : Self = Self :: ZERO ;
3436 const NEG_PI : Self = Self :: ZERO ;
3537 const FRAC_PI_2 : Self = Self :: ZERO ;
Original file line number Diff line number Diff line change 9696 ix = scaled. to_bits ( ) ;
9797 match top {
9898 Exp :: Shifted ( ref mut v) => {
99- * v = scaled. exp ( ) . unsigned ( ) ;
99+ * v = scaled. exp ( ) ;
100100 * v = ( * v) . wrapping_sub ( F :: SIG_BITS ) ;
101101 }
102102 Exp :: NoShift ( ( ) ) => {
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ pub trait Float:
3434 const NAN : Self ;
3535 const MAX : Self ;
3636 const MIN : Self ;
37+ const EPSILON : Self ;
3738 const PI : Self ;
3839 const NEG_PI : Self ;
3940 const FRAC_PI_2 : Self ;
@@ -107,13 +108,13 @@ pub trait Float:
107108 }
108109
109110 /// 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
112113 }
113114
114115 /// Extract the exponent and adjust it for bias, not accounting for subnormals or zero.
115116 fn exp_unbiased ( self ) -> i32 {
116- self . exp ( ) - ( Self :: EXP_BIAS as i32 )
117+ self . exp ( ) . signed ( ) - ( Self :: EXP_BIAS as i32 )
117118 }
118119
119120 /// Returns the significand with no implicit bit (or the "fractional" part)
@@ -180,6 +181,7 @@ macro_rules! float_impl {
180181 const MAX : Self = -Self :: MIN ;
181182 // Sign bit set, saturated mantissa, saturated exponent with last bit zeroed
182183 const MIN : Self = $from_bits( Self :: Int :: MAX & !( 1 << Self :: SIG_BITS ) ) ;
184+ const EPSILON : Self = <$ty>:: EPSILON ;
183185
184186 const PI : Self = core:: $ty:: consts:: PI ;
185187 const NEG_PI : Self = -Self :: PI ;
You can’t perform that action at this time.
0 commit comments