Standard library / math/big

big.Rat.Sign()

Report rational sign as -1, 0 or 1. Expected stdout: '-1 0 1\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Rat) Sign() int

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.NewRat(-1, 2).Sign(), big.NewRat(0, 1).Sign(), big.NewRat(1, 2).Sign())}
Go Reference