Standard library / go/constant

go/constant.ToFloat()

Convert a representable numeric constant to Float, otherwise Unknown. Expected stdout: 'Float\n'.

Formal Syntax & Structure

go syntaxgo
func ToFloat(x Value) Value

Parameters & Attributes

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

Return Value

Value

Convert a representable numeric constant to Float, otherwise Unknown.

Working Example

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