Standard library / strconv
strconv.ParseFloat()
Parses decimal or hexadecimal floating-point text, plus documented special values. bitSize selects 32- or 64-bit rounding, but return type is float64. Check range and syntax errors. Expected stdout: '6 <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func ParseFloat(s string, bitSize int) (float64, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text to parse, inspect or quote. |
| bitSize | int | Floating-point precision width, 32 or 64. |
Return Value
(float64, error)
Decoded or parsed value and error; inspect the error before using the result.
Working Example
Example Snippetgo
package main
import ( "fmt" "strconv")
func main() { v, e := strconv.ParseFloat("0x1.8p2", 64) fmt.Println(v, e)}