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