aboutsummaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-12-09 16:31:54 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-12-09 16:31:54 +0100
commitb2b79b86f00a229cc9d9cc0226ffb594a4e4d910 (patch)
treeb45edc26c3fa36938d3235c6383d014b59e7db2b /core/math
parentc94098c2ab550425075509e3031bacc3a588a6db (diff)
[math/big] Return 0, .Integer_Underflow if trying to get a negative number to an unsigned int.
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 abe592f9b..70914228e 100644
--- a/core/math/big/internal.odin
+++ b/core/math/big/internal.odin
@@ -2332,7 +2332,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 {