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) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | Value | Input 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))) }