Standard library / math/big
big.ParseFloat()
Parses text with specified base, bit precision and rounding mode; returns value, actual base and error. Expected stdout: '1.25 10 <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func ParseFloat(s string, base int, prec uint, mode RoundingMode) (f *Float, b int, err error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text. |
| base | int | Numeric radix. |
| prec | uint | Precision in bits. |
| mode | RoundingMode | Rounding mode. |
Return Value
(f *Float, b int, err error)
Parses text with specified base, bit precision and rounding mode; returns value, actual base and error.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/big")
func main() { v, b, e := big.ParseFloat("1.25", 10, 80, big.ToNearestEven) fmt.Println(v, b, e)}