Standard library / math/big
big.Rat.SetFloat64()
Represent the existing finite float64 exactly as a rational; nonfinite input returns nil. This does not recover a decimal literal's intended exact value. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '3602879701896397/36028797018963968\n'.
Formal Syntax & Structure
go syntaxgo
func (z *Rat) SetFloat64(f float64) *RatParameters & Attributes
| Name | Type | Description |
|---|---|---|
| f | float64 | Numeric 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).SetFloat64(0.1))}