Standard library / math/big

big.Rat.SetInt64()

Set a signed 64-bit integer as an exact rational. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '-42/1\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Rat) SetInt64(x int64) *Rat

Parameters & Attributes

NameTypeDescription
xint64Numeric operand supplied to this method.

Return Value

*Rat

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(new(big.Rat).SetInt64(-42))}
Go Reference