Standard library / math/big

big.Float.Text()

Format using a selected verb and precision; negative precision requests a shortest representation for applicable formats. Expected stdout: '1.2500\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Float) Text(format byte, prec int) string

Parameters & Attributes

NameTypeDescription
formatbyteFormatting verb.
precintFormatting precision.

Return Value

string

Returns the result described above; see the example for the observed behavior.

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  fmt.Println(big.NewFloat(1.25).Text('f', 4))}
Go Reference