Standard library / math/big
big.Float.Parse()
Parse a complete floating-point string in base 0, 2, 8, 10 or 16. Base 0 detects prefixes; invalid bases panic and malformed strings return errors. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '6 16\n'.
Formal Syntax & Structure
go syntaxgo
func (z *Float) Parse(s string, base int) (f *Float, b int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Text input or formatting/scanning state, according to the signature. |
| base | int | Numeric radix; consult the accepted range. |
Return Value
(f *Float, b int, err error)
Returns the result described above; see the example for the observed behavior.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/big")
func check(err error) { if err != nil { panic(err) }}func main() { z, b, e := new(big.Float).Parse("0x1.8p2", 0) check(e) fmt.Println(z, b)}