# std.math.big.int: fix shiftRight sign handling · gitcafe/zig

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

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

Visibility: public

Requested revision: 3543f283208951514c0fdb45b0dde7393e5e40c7

Requested commit: 3543f283208951514c0fdb45b0dde7393e5e40c7

Commit: 3543f283208951514c0fdb45b0dde7393e5e40c7

Tree: bf1b41d57db171388b42e827a0e96c05175b7ef0

Author: Ian Johnson

Committer: Andrew Kelley

## Message

```
std.math.big.int: fix shiftRight sign handling

Closes #21311

The sign of the result `r` needs to be initialized before the correction
`r.addScalar(r.toConst(), -1)`, or the intended end result could be off
by 2 (depending on the original sign of `r`).

```

## Parents

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

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