Standard library / math/big

big.Float.Sub()

Subtract and round according to receiver settings. Subtracting same-sign infinities panics with ErrNaN. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '3.25\n'.

Formal Syntax & Structure

go syntaxgo
func (z *Float) Sub(x, y *Float) *Float

Parameters & Attributes

NameTypeDescription
x*FloatNumeric operand supplied to this method.
y*FloatNumeric operand supplied to this method.

Return Value

*Float

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.Float).Sub(big.NewFloat(5.5), big.NewFloat(2.25)))}
Go Reference