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