@@ -41,6 +41,8 @@ pub trait Float:
4141 const NEG_PI : Self ;
4242 const FRAC_PI_2 : Self ;
4343
44+ const MIN_POSITIVE_NORMAL : Self ;
45+
4446 /// The bitwidth of the float type
4547 const BITS : u32 ;
4648
@@ -200,6 +202,9 @@ macro_rules! float_impl {
200202 const MIN : Self = $from_bits( Self :: Int :: MAX & !( 1 << Self :: SIG_BITS ) ) ;
201203 const EPSILON : Self = <$ty>:: EPSILON ;
202204
205+ // Exponent is a 1 in the LSB
206+ const MIN_POSITIVE_NORMAL : Self = $from_bits( 1 << Self :: SIG_BITS ) ;
207+
203208 const PI : Self = core:: $ty:: consts:: PI ;
204209 const NEG_PI : Self = -Self :: PI ;
205210 const FRAC_PI_2 : Self = core:: $ty:: consts:: FRAC_PI_2 ;
@@ -358,6 +363,7 @@ mod tests {
358363 // results for zero and subnormals.
359364 assert_eq ! ( f16:: ZERO . exp_unbiased( ) , -15 ) ;
360365 assert_eq ! ( f16:: from_bits( 0x1 ) . exp_unbiased( ) , -15 ) ;
366+ assert_eq ! ( f16:: MIN_POSITIVE , f16:: MIN_POSITIVE_NORMAL ) ;
361367
362368 // `from_parts`
363369 assert_biteq ! ( f16:: from_parts( true , f16:: EXP_BIAS , 0 ) , -1.0f16 ) ;
@@ -383,6 +389,7 @@ mod tests {
383389 // results for zero and subnormals.
384390 assert_eq ! ( f32 :: ZERO . exp_unbiased( ) , -127 ) ;
385391 assert_eq ! ( f32 :: from_bits( 0x1 ) . exp_unbiased( ) , -127 ) ;
392+ assert_eq ! ( f32 :: MIN_POSITIVE , f32 :: MIN_POSITIVE_NORMAL ) ;
386393
387394 // `from_parts`
388395 assert_biteq ! ( f32 :: from_parts( true , f32 :: EXP_BIAS , 0 ) , -1.0f32 ) ;
@@ -409,6 +416,7 @@ mod tests {
409416 // results for zero and subnormals.
410417 assert_eq ! ( f64 :: ZERO . exp_unbiased( ) , -1023 ) ;
411418 assert_eq ! ( f64 :: from_bits( 0x1 ) . exp_unbiased( ) , -1023 ) ;
419+ assert_eq ! ( f64 :: MIN_POSITIVE , f64 :: MIN_POSITIVE_NORMAL ) ;
412420
413421 // `from_parts`
414422 assert_biteq ! ( f64 :: from_parts( true , f64 :: EXP_BIAS , 0 ) , -1.0f64 ) ;
@@ -436,6 +444,7 @@ mod tests {
436444 // results for zero and subnormals.
437445 assert_eq ! ( f128:: ZERO . exp_unbiased( ) , -16383 ) ;
438446 assert_eq ! ( f128:: from_bits( 0x1 ) . exp_unbiased( ) , -16383 ) ;
447+ assert_eq ! ( f128:: MIN_POSITIVE , f128:: MIN_POSITIVE_NORMAL ) ;
439448
440449 // `from_parts`
441450 assert_biteq ! ( f128:: from_parts( true , f128:: EXP_BIAS , 0 ) , -1.0f128 ) ;
0 commit comments