Standard library / math/big
big.Int.Sign()
Return -1 for negative, 0 for zero, or 1 for positive integers. Expected stdout: '-1 0 1\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Int) Sign() intReturn 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(-2).Sign(), big.NewInt(0).Sign(), big.NewInt(2).Sign())}