aboutsummaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-12-09 16:41:37 +0100
committerGitHub <noreply@github.com>2021-12-09 16:41:37 +0100
commitc771ea9794b76a0f433651a38dc940c9c991663d (patch)
tree2b178866c4508777a2cc2508c7280ee490c5174e /core/math
parent94bad4d7861c78b9e7191ec0c3114861a1536d5c (diff)
parentb2b79b86f00a229cc9d9cc0226ffb594a4e4d910 (diff)
Merge pull request #1358 from Kelimion/big_math_fix
[math/big] Return 0, .Integer_Underflow if T = unsigned and bigint is negative.
Diffstat (limited to 'core/math')
-rw-r--r--core/math/big/internal.odin5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/math/big/internal.odin b/core/math/big/internal.odin
index 2d412d84e..69497b150 100644
--- a/core/math/big/internal.odin
+++ b/core/math/big/internal.odin
@@ -2362,7 +2362,12 @@ internal_int_get :: proc(a: ^Int, $T: typeid) -> (res: T, err: Error) where intr
if a.sign == .Zero_or_Positive {
target_bit_size -= 1
}
+ } else {
+ if a.sign == .Negative {
+ return 0, .Integer_Underflow
+ }
}
+
bits_used := internal_count_bits(a)
if bits_used > target_bit_size {