Standard library / math/big
big.Rat.FloatString()
Formats a rational with fixed decimal precision, rounding ties away from zero. Expected stdout: '0.13\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Rat) FloatString(prec int) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| prec | int | Precision in bits. |
Return Value
string
Formats a rational with fixed decimal precision, rounding ties away from zero.
Working Example
Example Snippetgo
package main
import ( "fmt" "math/big")
func main() { fmt.Println(big.NewRat(1, 8).FloatString(2))}