Standard library / math/big

big.Rat.FloatPrec()

Return number of nonrepeating decimal fractional digits and whether that many digits represent the fraction exactly. Expected stdout: '3 true 1 false\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Rat) FloatPrec() (n int, exact bool)

Return Value

(n int, exact bool)

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

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  n, a := big.NewRat(1, 8).FloatPrec()  m, b := big.NewRat(1, 6).FloatPrec()  fmt.Println(n, a, m, b)}
Go Reference