Standard library / math/big

big.Int.Rsh()

Shift right arithmetically; negative values round toward negative infinity under division by powers of two. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '-4\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) Rsh(x *Int, n uint) *Int

Parameters & Attributes

NameTypeDescription
x*IntNumeric operand supplied to this method.
nuintCount, bound, modulus or shift amount, as described above.

Return Value

*Int

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(new(big.Int).Rsh(big.NewInt(-7), 1))}
Go Reference