Standard library / math/big

big.Rat.RatString()

Format as a/b except that integer values omit the denominator. Expected stdout: '2 2/3\n'.

Formal Syntax & Structure

go syntaxgo
func (x *Rat) RatString() string

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.NewRat(6, 3).RatString(), big.NewRat(2, 3).RatString())}
Go Reference