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

NameTypeDescription
sstringInput text.
baseintNumeric radix.
precuintPrecision in bits.
modeRoundingModeRounding 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)}
Go Reference