@@ -41,6 +41,8 @@ pub trait Float:
41
41
const NEG_PI : Self ;
42
42
const FRAC_PI_2 : Self ;
43
43
44
+ const MIN_POSITIVE_NORMAL : Self ;
45
+
44
46
/// The bitwidth of the float type
45
47
const BITS : u32 ;
46
48
@@ -200,6 +202,9 @@ macro_rules! float_impl {
200
202
const MIN : Self = $from_bits( Self :: Int :: MAX & !( 1 << Self :: SIG_BITS ) ) ;
201
203
const EPSILON : Self = <$ty>:: EPSILON ;
202
204
205
+ // Exponent is a 1 in the LSB
206
+ const MIN_POSITIVE_NORMAL : Self = $from_bits( 1 << Self :: SIG_BITS ) ;
207
+
203
208
const PI : Self = core:: $ty:: consts:: PI ;
204
209
const NEG_PI : Self = -Self :: PI ;
205
210
const FRAC_PI_2 : Self = core:: $ty:: consts:: FRAC_PI_2 ;
@@ -358,6 +363,7 @@ mod tests {
358
363
// results for zero and subnormals.
359
364
assert_eq ! ( f16:: ZERO . exp_unbiased( ) , -15 ) ;
360
365
assert_eq ! ( f16:: from_bits( 0x1 ) . exp_unbiased( ) , -15 ) ;
366
+ assert_eq ! ( f16:: MIN_POSITIVE , f16:: MIN_POSITIVE_NORMAL ) ;
361
367
362
368
// `from_parts`
363
369
assert_biteq ! ( f16:: from_parts( true , f16:: EXP_BIAS , 0 ) , -1.0f16 ) ;
@@ -383,6 +389,7 @@ mod tests {
383
389
// results for zero and subnormals.
384
390
assert_eq ! ( f32 :: ZERO . exp_unbiased( ) , -127 ) ;
385
391
assert_eq ! ( f32 :: from_bits( 0x1 ) . exp_unbiased( ) , -127 ) ;
392
+ assert_eq ! ( f32 :: MIN_POSITIVE , f32 :: MIN_POSITIVE_NORMAL ) ;
386
393
387
394
// `from_parts`
388
395
assert_biteq ! ( f32 :: from_parts( true , f32 :: EXP_BIAS , 0 ) , -1.0f32 ) ;
@@ -409,6 +416,7 @@ mod tests {
409
416
// results for zero and subnormals.
410
417
assert_eq ! ( f64 :: ZERO . exp_unbiased( ) , -1023 ) ;
411
418
assert_eq ! ( f64 :: from_bits( 0x1 ) . exp_unbiased( ) , -1023 ) ;
419
+ assert_eq ! ( f64 :: MIN_POSITIVE , f64 :: MIN_POSITIVE_NORMAL ) ;
412
420
413
421
// `from_parts`
414
422
assert_biteq ! ( f64 :: from_parts( true , f64 :: EXP_BIAS , 0 ) , -1.0f64 ) ;
@@ -436,6 +444,7 @@ mod tests {
436
444
// results for zero and subnormals.
437
445
assert_eq ! ( f128:: ZERO . exp_unbiased( ) , -16383 ) ;
438
446
assert_eq ! ( f128:: from_bits( 0x1 ) . exp_unbiased( ) , -16383 ) ;
447
+ assert_eq ! ( f128:: MIN_POSITIVE , f128:: MIN_POSITIVE_NORMAL ) ;
439
448
440
449
// `from_parts`
441
450
assert_biteq ! ( f128:: from_parts( true , f128:: EXP_BIAS , 0 ) , -1.0f128 ) ;
0 commit comments