Standard library / go/constant

go/constant.Num()

Return a signed integer numerator for a real numeric constant, or Unknown when a supported fraction cannot be represented. Expected stdout: '1\n'.

Formal Syntax & Structure

go syntaxgo
func Num(x Value) Value

Parameters & Attributes

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

Return Value

Value

Return a signed integer numerator for a real numeric constant, or Unknown when a supported fraction cannot be represented.

Working Example

Example Snippetgo
package main
import (  "fmt"  "go/constant"  "go/token")
func main() { fmt.Println(constant.Num(constant.MakeFromLiteral("0.1", token.FLOAT, 0))) }
Go Reference