Standard library / go/constant

go/constant.Sign()

Return the real constant sign; complex results distinguish zero from nonzero only. Unknown returns 1. Expected stdout: '-1\n'.

Formal Syntax & Structure

go syntaxgo
func Sign(x Value) int

Parameters & Attributes

NameTypeDescription
xValueInput constant or Go value as specified by the function.

Return Value

int

Return the real constant sign; complex results distinguish zero from nonzero only.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/constant")
func main() { fmt.Println(constant.Sign(constant.MakeInt64(-42))) }
Go Reference