@@ -48,8 +48,8 @@ macro_rules! impl_full_ops {
48
48
impl FullOps for $ty {
49
49
#[ cfg( stage0) ]
50
50
fn full_add( self , other: $ty, carry: bool ) -> ( bool , $ty) {
51
- // this cannot overflow, the output is between 0 and 2* 2^nbits - 1
52
- // FIXME will LLVM optimize this into ADC or similar?? ?
51
+ // This cannot overflow; the output is between `0` and `2 * 2^nbits - 1`.
52
+ // FIXME: will LLVM optimize this into ADC or similar?
53
53
let ( v, carry1) = unsafe { intrinsics:: add_with_overflow( self , other) } ;
54
54
let ( v, carry2) = unsafe {
55
55
intrinsics:: add_with_overflow( v, if carry { 1 } else { 0 } )
@@ -58,22 +58,25 @@ macro_rules! impl_full_ops {
58
58
}
59
59
#[ cfg( not( stage0) ) ]
60
60
fn full_add( self , other: $ty, carry: bool ) -> ( bool , $ty) {
61
- // this cannot overflow, the output is between 0 and 2* 2^nbits - 1
62
- // FIXME will LLVM optimize this into ADC or similar?? ?
61
+ // This cannot overflow; the output is between `0` and `2 * 2^nbits - 1`.
62
+ // FIXME: will LLVM optimize this into ADC or similar?
63
63
let ( v, carry1) = intrinsics:: add_with_overflow( self , other) ;
64
64
let ( v, carry2) = intrinsics:: add_with_overflow( v, if carry { 1 } else { 0 } ) ;
65
65
( carry1 || carry2, v)
66
66
}
67
67
68
68
fn full_mul( self , other: $ty, carry: $ty) -> ( $ty, $ty) {
69
- // this cannot overflow, the output is between 0 and 2^nbits * (2^nbits - 1)
69
+ // This cannot overflow;
70
+ // the output is between `0` and `2^nbits * (2^nbits - 1)`.
71
+ // FIXME: will LLVM optimize this into ADC or similar?
70
72
let nbits = mem:: size_of:: <$ty>( ) * 8 ;
71
73
let v = ( self as $bigty) * ( other as $bigty) + ( carry as $bigty) ;
72
74
( ( v >> nbits) as $ty, v as $ty)
73
75
}
74
76
75
77
fn full_mul_add( self , other: $ty, other2: $ty, carry: $ty) -> ( $ty, $ty) {
76
- // this cannot overflow, the output is between 0 and 2^(2*nbits) - 1
78
+ // This cannot overflow;
79
+ // the output is between `0` and `2^nbits * (2^nbits - 1)`.
77
80
let nbits = mem:: size_of:: <$ty>( ) * 8 ;
78
81
let v = ( self as $bigty) * ( other as $bigty) + ( other2 as $bigty) +
79
82
( carry as $bigty) ;
@@ -82,7 +85,7 @@ macro_rules! impl_full_ops {
82
85
83
86
fn full_div_rem( self , other: $ty, borrow: $ty) -> ( $ty, $ty) {
84
87
debug_assert!( borrow < other) ;
85
- // this cannot overflow, the dividend is between 0 and other * 2^nbits - 1
88
+ // This cannot overflow; the output is between `0` and ` other * ( 2^nbits - 1)`.
86
89
let nbits = mem:: size_of:: <$ty>( ) * 8 ;
87
90
let lhs = ( ( borrow as $bigty) << nbits) | ( self as $bigty) ;
88
91
let rhs = other as $bigty;
@@ -97,7 +100,8 @@ impl_full_ops! {
97
100
u8 : add( intrinsics:: u8_add_with_overflow) , mul/div( u16 ) ;
98
101
u16 : add( intrinsics:: u16_add_with_overflow) , mul/div( u32 ) ;
99
102
u32 : add( intrinsics:: u32_add_with_overflow) , mul/div( u64 ) ;
100
- // u64: add(intrinsics::u64_add_with_overflow), mul/div(u128); // see RFC #521 for enabling this.
103
+ // See RFC #521 for enabling this.
104
+ // u64: add(intrinsics::u64_add_with_overflow), mul/div(u128);
101
105
}
102
106
103
107
/// Table of powers of 5 representable in digits. Specifically, the largest {u8, u16, u32} value
0 commit comments