Standard library / math/big

big.Float.Rat()

Convert the exact stored binary value to a rational, optionally reusing a Rat. Infinity returns nil. Expected stdout: '5/4 Exact\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Float) Rat(z *Rat) (*Rat, Accuracy)

Parameters & Attributes

NameTypeDescription
z*RatOptional destination for the converted result.

Return Value

(*Rat, Accuracy)

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

Working Example

Example Snippetgo
package main
import (  "fmt"  "math/big")
func main() {  r, a := big.NewFloat(1.25).Rat(nil)  fmt.Println(r, a)}
Go Reference