File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1290,8 +1290,10 @@ macro_rules! try_from_secs {
1290
1290
1291
1291
// note that neither `f32`, nor `f64` can represent
1292
1292
// 0.999_999_999_5 exactly, so the nanos part
1293
- // never will be equal to 10^9.
1294
- ( 0 , nanos + add_ns as u32 )
1293
+ // never will be equal to NANOS_PER_SEC
1294
+ let nanos = nanos + add_ns as u32 ;
1295
+ debug_assert!( nanos < NANOS_PER_SEC ) ;
1296
+ ( 0 , nanos)
1295
1297
} else if exp < $mant_bits {
1296
1298
let secs = u64 :: from( mant >> ( $mant_bits - exp) ) ;
1297
1299
let t = <$double_ty>:: from( ( mant << exp) & MANT_MASK ) ;
@@ -1308,8 +1310,10 @@ macro_rules! try_from_secs {
1308
1310
let add_ns = !( rem_msb || ( is_even && is_tie) ) ;
1309
1311
1310
1312
// neither `f32`, nor `f64` can represent x.999_999_999_5 exactly,
1311
- // so the nanos part never will be equal to 10^9
1312
- ( secs, nanos + add_ns as u32 )
1313
+ // so the nanos part never will be equal to NANOS_PER_SEC
1314
+ let nanos = nanos + add_ns as u32 ;
1315
+ debug_assert!( nanos < NANOS_PER_SEC ) ;
1316
+ ( secs, nanos)
1313
1317
} else if exp < 64 {
1314
1318
// the input has no fractional part
1315
1319
let secs = u64 :: from( mant) << ( exp - $mant_bits) ;
You can’t perform that action at this time.
0 commit comments