Standard library / math/big

big.Int.QuoRem()

Compute quotient truncated toward zero and remainder with the dividend's sign or zero. Divisor zero panics. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '-2 -1\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Int) QuoRem(x, y, r *Int) (*Int, *Int)

Parameters & Attributes

NameTypeDescription
x*IntNumeric operand supplied to this method.
y*IntNumeric operand supplied to this method.
r*IntDestination for the remainder.

Return Value

(*Int, *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() {  q, r := new(big.Int).QuoRem(big.NewInt(-7), big.NewInt(3), new(big.Int))  fmt.Println(q, r)}
Go Reference