mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 05:48:31 +00:00
Fix increment operation for bigint -1
This commit is contained in:
parent
eb6a8e6a3b
commit
0ab4afbf42
@ -1683,10 +1683,20 @@ void bigint_incr(BigInt *x) {
|
||||
bigint_init_unsigned(x, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (x->digit_count == 1 && x->data.digit != UINT64_MAX) {
|
||||
x->data.digit += 1;
|
||||
return;
|
||||
|
||||
if (x->digit_count == 1) {
|
||||
if (x->is_negative) {
|
||||
if (x->data.digit != 0) {
|
||||
x->data.digit -= 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (x->data.digit != UINT64_MAX) {
|
||||
x->data.digit += 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BigInt copy;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user