Standard library / math/big

big.Float.Cmp()

Compare numeric values, including infinities and signed zeros, returning -1, 0 or 1. Expected stdout: '-1\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Float) Cmp(y *Float) int

Parameters & Attributes

NameTypeDescription
y*FloatNumeric 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.NewFloat(1.25).Cmp(big.NewFloat(2.5)))}
Go Reference