Standard library / go/constant
go/constant.Float32Val()
Round a real numeric constant to float32 and report exactness. Expected stdout: '0.1 false\n'.
Formal Syntax & Structure
go syntaxgo
func Float32Val(x Value) (float32, bool)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | Value | Input constant or Go value as specified by the function. |
Return Value
(float32, bool)
Round a real numeric constant to float32 and report exactness.
Working Example
Example Snippetgo
package main
import ( "fmt" "go/constant" "go/token")
func main() { v, exact := constant.Float32Val(constant.MakeFromLiteral("0.1", token.FLOAT, 0)) fmt.Println(v, exact)}