@@ -31,10 +31,10 @@ pub(crate) trait Float:
31
31
+ ops:: Rem <Output = Self >
32
32
{
33
33
/// A uint of the same width as the float
34
- type Int : Int ;
34
+ type Int : Int < OtherSign = Self :: SignedInt , UnsignedInt = Self :: Int > ;
35
35
36
36
/// A int of the same width as the float
37
- type SignedInt : Int ;
37
+ type SignedInt : Int + MinInt < OtherSign = Self :: Int , UnsignedInt = Self :: Int > ;
38
38
39
39
/// An int capable of containing the exponent bits plus a sign bit. This is signed.
40
40
type ExpInt : Int ;
@@ -51,7 +51,7 @@ pub(crate) trait Float:
51
51
/// The bitwidth of the exponent
52
52
const EXPONENT_BITS : u32 = Self :: BITS - Self :: SIGNIFICAND_BITS - 1 ;
53
53
54
- /// The maximum value of the exponent
54
+ /// The saturated value of the exponent (infinite representation), in the rightmost postiion.
55
55
const EXPONENT_MAX : u32 = ( 1 << Self :: EXPONENT_BITS ) - 1 ;
56
56
57
57
/// The exponent bias value
@@ -83,7 +83,7 @@ pub(crate) trait Float:
83
83
/// Returns true if the sign is negative
84
84
fn is_sign_negative( self ) -> bool ;
85
85
86
- /// Returns the exponent with bias
86
+ /// Returns the exponent, not adjusting for bias.
87
87
fn exp( self ) -> Self :: ExpInt ;
88
88
89
89
/// Returns the significand with no implicit bit (or the "fractional" part)
@@ -175,7 +175,7 @@ macro_rules! float_impl {
175
175
fn normalize( significand: Self :: Int ) -> ( i32 , Self :: Int ) {
176
176
let shift = significand
177
177
. leading_zeros( )
178
- . wrapping_sub( ( Self :: Int :: ONE << Self :: SIGNIFICAND_BITS ) . leading_zeros ( ) ) ;
178
+ . wrapping_sub( Self :: EXPONENT_BITS ) ;
179
179
(
180
180
1i32 . wrapping_sub( shift as i32 ) ,
181
181
significand << shift as Self :: Int ,
0 commit comments