Standard library / math/big

big.Int.CmpAbs()

Compare absolute magnitudes rather than signed values. Expected stdout: '1\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Int) CmpAbs(y *Int) int

Parameters & Attributes

NameTypeDescription
y*IntNumeric operand supplied to this method.

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(big.NewInt(-9).CmpAbs(big.NewInt(4)))}
Go Reference