Skip to content

Commit ee6eed3

Browse files
authored
math.unsigned: replace untested comments for uint256 public APIs (#24873)
1 parent 03e72a4 commit ee6eed3

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

vlib/math/unsigned/uint256.v

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn (u Uint256) xor_128(v Uint128) Uint256 {
9494
return Uint256{u.lo.xor(v), u.hi}
9595
}
9696

97-
// add_256 - untested
97+
// add_256 return u + v and the carry
9898
pub fn add_256(x Uint256, y Uint256, carry u64) (Uint256, u64) {
9999
mut sum := Uint256{}
100100
mut carry_out := u64(0)
@@ -103,7 +103,7 @@ pub fn add_256(x Uint256, y Uint256, carry u64) (Uint256, u64) {
103103
return sum, carry_out
104104
}
105105

106-
// sub_256 - untested
106+
// sub_256 returns u - v and the borrow
107107
pub fn sub_256(x Uint256, y Uint256, borrow u64) (Uint256, u64) {
108108
mut diff := Uint256{}
109109
mut borrow_out := u64(0)
@@ -112,7 +112,7 @@ pub fn sub_256(x Uint256, y Uint256, borrow u64) (Uint256, u64) {
112112
return diff, borrow_out
113113
}
114114

115-
// mul_256 - untested
115+
// mul_256 returns u x v
116116
pub fn mul_256(x Uint256, y Uint256) (Uint256, Uint256) {
117117
mut hi := Uint256{}
118118
mut lo := Uint256{}
@@ -140,7 +140,7 @@ pub fn (u Uint256) add(v Uint256) Uint256 {
140140
return sum
141141
}
142142

143-
// overflowing_add - untested
143+
// overflowing_add returns u + v even if result size > 256
144144
pub fn (u Uint256) overflowing_add(v Uint256) (Uint256, u64) {
145145
sum, overflow := add_256(u, v, 0)
146146
return sum, overflow
@@ -178,7 +178,7 @@ pub fn (u Uint256) mul_128(v Uint128) Uint256 {
178178
return Uint256{lo, hi.add(u.hi.mul(v))}
179179
}
180180

181-
// quo_rem - untested
181+
// quo_rem returns q = u/v and r = u%v
182182
pub fn (u Uint256) quo_rem(v Uint256) (Uint256, Uint256) {
183183
if v.hi.is_zero() && v.lo.hi == 0 {
184184
q, r := u.quo_rem_64(v.lo.lo)
@@ -206,7 +206,7 @@ pub fn (u Uint256) quo_rem(v Uint256) (Uint256, Uint256) {
206206
return q, r
207207
}
208208

209-
// quo_rem_128 - untested
209+
// quo_rem_128 returns q = u/v and r = u%v
210210
pub fn (u Uint256) quo_rem_128(v Uint128) (Uint256, Uint128) {
211211
if u.hi.cmp(v) < 0 {
212212
lo, r := div_128(u.hi, u.lo, v)
@@ -218,7 +218,7 @@ pub fn (u Uint256) quo_rem_128(v Uint128) (Uint256, Uint128) {
218218
return Uint256{lo, hi}, r2
219219
}
220220

221-
// quo_rem_64 - untested
221+
// quo_rem_64 returns q = u/v and r = u%v
222222
pub fn (u Uint256) quo_rem_64(v u64) (Uint256, u64) {
223223
mut q := Uint256{}
224224
mut r := u64(0)
@@ -287,37 +287,37 @@ pub fn (u Uint256) lsh(n u32) Uint256 {
287287
return s
288288
}
289289

290-
// div - untested
290+
// div returns u / v
291291
pub fn (u Uint256) div(v Uint256) Uint256 {
292292
q, _ := u.quo_rem(v)
293293
return q
294294
}
295295

296-
// div_128 - untested
296+
// div_128 returns u / v
297297
pub fn (u Uint256) div_128(v Uint128) Uint256 {
298298
q, _ := u.quo_rem_128(v)
299299
return q
300300
}
301301

302-
// div_64 - untested
302+
// div_64 returns u / v
303303
pub fn (u Uint256) div_64(v u64) Uint256 {
304304
q, _ := u.quo_rem_64(v)
305305
return q
306306
}
307307

308-
// mod - untested
308+
// mod returns r = u % v
309309
pub fn (u Uint256) mod(v Uint256) Uint256 {
310310
_, r := u.quo_rem(v)
311311
return r
312312
}
313313

314-
// mod_128 - untested
314+
// mod_128 returns r = u % v
315315
pub fn (u Uint256) mod_128(v Uint128) Uint128 {
316316
_, r := u.quo_rem_128(v)
317317
return r
318318
}
319319

320-
// mod_64 - untested
320+
// mod_64 returns r = u % v
321321
pub fn (u Uint256) mod_64(v u64) u64 {
322322
_, r := u.quo_rem_64(v)
323323
return r

0 commit comments

Comments
 (0)