mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-20 08:26:47 +00:00
[math/big] Return 0, .Integer_Underflow if trying to get a negative number to an unsigned int.
This commit is contained in:
@@ -2332,7 +2332,12 @@ internal_int_get :: proc(a: ^Int, $T: typeid) -> (res: T, err: Error) where intr
|
|||||||
if a.sign == .Zero_or_Positive {
|
if a.sign == .Zero_or_Positive {
|
||||||
target_bit_size -= 1
|
target_bit_size -= 1
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if a.sign == .Negative {
|
||||||
|
return 0, .Integer_Underflow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bits_used := internal_count_bits(a)
|
bits_used := internal_count_bits(a)
|
||||||
|
|
||||||
if bits_used > target_bit_size {
|
if bits_used > target_bit_size {
|
||||||
|
|||||||
Reference in New Issue
Block a user