1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

math.big: remove import math dependency (math.big only uses min/max/abs)

This commit is contained in:
Delyan Angelov
2022-11-29 14:21:16 +02:00
parent 6ef3dfdea9
commit 952f4644c5
4 changed files with 43 additions and 23 deletions

View File

@@ -1,7 +1,5 @@
module big
import math
// Compares the magnitude of the two unsigned integers represented the given
// digit arrays. Returns -1 if a < b, 0 if a == b and +1 if a > b. Here
// a is operand_a and b is operand_b (for brevity).
@@ -42,8 +40,8 @@ fn add_digit_array(operand_a []u32, operand_b []u32, mut sum []u32) {
}
// First pass intersects with both operands
smaller_limit := math.min(operand_a.len, operand_b.len)
larger_limit := math.max(operand_a.len, operand_b.len)
smaller_limit := imin(operand_a.len, operand_b.len)
larger_limit := imax(operand_a.len, operand_b.len)
mut a, mut b := if operand_a.len >= operand_b.len {
operand_a, operand_b
} else {
@@ -311,7 +309,7 @@ fn bitwise_or_digit_array(operand_a []u32, operand_b []u32, mut storage []u32) {
[direct_array_access]
fn bitwise_and_digit_array(operand_a []u32, operand_b []u32, mut storage []u32) {
lower := math.min(operand_a.len, operand_b.len)
lower := imin(operand_a.len, operand_b.len)
for index in 0 .. lower {
storage[index] = operand_a[index] & operand_b[index]
}