aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-11-27 09:13:21 +0000
committergingerBill <gingerBill@users.noreply.github.com>2025-11-27 09:13:21 +0000
commitc63fa3f6630f350b3b2e9744dec35e269c500ee3 (patch)
tree4dc58d8e0885b629c4d0e221ee2b518aaf8c880c /core
parent53876907c61faaadf68ae8b8140ed55df3f691d3 (diff)
Use `< 0` instead of `== -1` for comparisons
Diffstat (limited to 'core')
-rw-r--r--core/math/big/internal.odin8
-rw-r--r--core/math/big/prime.odin2
-rw-r--r--core/math/big/private.odin10
-rw-r--r--core/math/big/public.odin6
-rw-r--r--core/math/big/radix.odin2
5 files changed, 14 insertions, 14 deletions
diff --git a/core/math/big/internal.odin b/core/math/big/internal.odin
index 723bb0b8d..4bb45397d 100644
--- a/core/math/big/internal.odin
+++ b/core/math/big/internal.odin
@@ -1199,14 +1199,14 @@ internal_cmp_mag :: internal_compare_magnitude
bool := a < b
*/
internal_int_less_than :: #force_inline proc(a, b: ^Int) -> (less_than: bool) {
- return internal_cmp(a, b) == -1
+ return internal_cmp(a, b) < 0
}
/*
bool := a < b
*/
internal_int_less_than_digit :: #force_inline proc(a: ^Int, b: DIGIT) -> (less_than: bool) {
- return internal_cmp_digit(a, b) == -1
+ return internal_cmp_digit(a, b) < 0
}
/*
@@ -1214,7 +1214,7 @@ internal_int_less_than_digit :: #force_inline proc(a: ^Int, b: DIGIT) -> (less_t
Compares the magnitudes only, ignores the sign.
*/
internal_int_less_than_abs :: #force_inline proc(a, b: ^Int) -> (less_than: bool) {
- return internal_cmp_mag(a, b) == -1
+ return internal_cmp_mag(a, b) < 0
}
internal_less_than :: proc {
@@ -2933,7 +2933,7 @@ internal_int_zero_unused :: #force_inline proc(dest: ^Int, old_used := -1) {
If we don't pass the number of previously used DIGITs, we zero all remaining ones.
*/
zero_count: int
- if old_used == -1 {
+ if old_used < 0 {
zero_count = len(dest.digit) - dest.used
} else {
zero_count = old_used - dest.used
diff --git a/core/math/big/prime.odin b/core/math/big/prime.odin
index d7f902fa5..4fe502a20 100644
--- a/core/math/big/prime.odin
+++ b/core/math/big/prime.odin
@@ -1207,7 +1207,7 @@ internal_random_prime :: proc(a: ^Int, size_in_bits: int, trials: int, flags :=
/*
Automatically choose the number of Rabin-Miller trials?
*/
- if trials == -1 {
+ if trials < 0 {
trials = number_of_rabin_miller_trials(size_in_bits)
}
diff --git a/core/math/big/private.odin b/core/math/big/private.odin
index 4847b0074..2814b5429 100644
--- a/core/math/big/private.odin
+++ b/core/math/big/private.odin
@@ -1662,7 +1662,7 @@ _private_int_log :: proc(a: ^Int, base: DIGIT, allocator := context.allocator) -
defer internal_destroy(bracket_low, bracket_high, bracket_mid, t, bi_base)
ic := #force_inline internal_cmp(a, base)
- if ic == -1 || ic == 0 {
+ if ic <= 0 {
return 1 if ic == 0 else 0, nil
}
defer if err != nil {
@@ -2492,9 +2492,9 @@ _private_int_exponent_mod :: proc(res, G, X, P: ^Int, redmode: int, allocator :=
bitcnt -= 1
if bitcnt == 0 {
/*
- If digidx == -1 we are out of digits.
+ If digidx < 0 we are out of digits.
*/
- if digidx == -1 { break }
+ if digidx < 0 { break }
/*
Read next digit and reset the bitcnt.
@@ -2748,9 +2748,9 @@ _private_int_exponent_mod_fast :: proc(res, G, X, P: ^Int, redmode: int, allocat
bitcnt -= 1
if bitcnt == 0 {
/*
- If digidx == -1 we are out of digits so break.
+ If digidx < 0 we are out of digits so break.
*/
- if digidx == -1 { break }
+ if digidx < 0 { break }
/*
Read next digit and reset the bitcnt.
diff --git a/core/math/big/public.odin b/core/math/big/public.odin
index 723e2e04a..07d2a7f21 100644
--- a/core/math/big/public.odin
+++ b/core/math/big/public.odin
@@ -593,7 +593,7 @@ int_less_than :: #force_inline proc(a, b: ^Int, allocator := context.allocator)
c: int
c, err = cmp(a, b)
- return c == -1, err
+ return c < 0, err
}
/*
@@ -608,7 +608,7 @@ int_less_than_digit :: #force_inline proc(a: ^Int, b: DIGIT, allocator := contex
c: int
c, err = cmp(a, b)
- return c == -1, err
+ return c < 0, err
}
/*
@@ -624,7 +624,7 @@ int_less_than_abs :: #force_inline proc(a, b: ^Int, allocator := context.allocat
c: int
c, err = cmp_mag(a, b)
- return c == -1, err
+ return c < 0, err
}
less_than :: proc {
diff --git a/core/math/big/radix.odin b/core/math/big/radix.odin
index 4583ab0f7..a7f93b990 100644
--- a/core/math/big/radix.odin
+++ b/core/math/big/radix.odin
@@ -110,7 +110,7 @@ int_itoa_raw :: proc(a: ^Int, radix: i8, buffer: []u8, size := int(-1), zero_ter
/*
We weren't given a size. Let's compute it.
*/
- if size == -1 {
+ if size < 0 {
size = radix_size(a, radix, zero_terminate) or_return
}