Standard library / math/big
big.Rat.Cmp()
Compare exact rational values without converting to floats. Expected stdout: '-1\n'.
Formal Syntax & Structure
go syntaxgo
func (x *Rat) Cmp(y *Rat) intParameters & Attributes
| Name | Type | Description |
|---|---|---|
| y | *Rat | Numeric operand supplied to this method. |
Return Value
int
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(1, 3).Cmp(big.NewRat(2, 5)))}