Standard library / math/big

big.Int.Cmp()

Compares x and y, returning -1, 0 or +1. Expected stdout: '-1\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Int) Cmp(y *Int) (r int)

Parameters & Attributes

NameTypeDescription
y*IntSecond input operand.

Return Value

(r int)

Compares x and y, returning -1, 0 or +1.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(big.NewInt(2).Cmp(big.NewInt(3)))}
Go Reference