# std/math/big/int: normalize after a right shift · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/a03f9548d3dd32876f99f5b7bdf1d678c5a5b98e)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: a03f9548d3dd32876f99f5b7bdf1d678c5a5b98e

Requested commit: a03f9548d3dd32876f99f5b7bdf1d678c5a5b98e

Commit: a03f9548d3dd32876f99f5b7bdf1d678c5a5b98e

Tree: 157e2951f458d9f63c7e9cda2789f19b2dea36b0

Author: Frank Denis

Committer: Andrew Kelley

## Message

```
std/math/big/int: normalize after a right shift

After a right shift, top limbs may be all zero. However, without
normalization, the number of limbs is not going to change.

In order to check if a big number is zero, we used to assume that the
number of limbs is 1. Which may not be the case after right shifts,
even if the actual value is zero.

- Normalize after a right shift
- Add a test for that issue
- Check all the limbs in `eqlZero()`. It may not be necessary if
callers always remember to normalize before calling the function.
But checking all the limbs is very cheap and makes the function less
bug-prone.

```

## Parents

- [bf76501b5d46277d3706a1f0b92ba52f2a47d894](https://git.cafe/gitcafe/zig/commit/bf76501b5d46277d3706a1f0b92ba52f2a47d894?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/a03f9548d3dd32876f99f5b7bdf1d678c5a5b98e?format=markdown)
