Standard library / math/big
big.Float.Abs()
Set the receiver to the absolute value of x, rounded to receiver precision if needed. This method writes to the receiver (use a separate destination to preserve inputs when needed). Expected stdout: '2.5\n'.
Formal Syntax & Structure
go syntaxgo
func (z *Float) Abs(x *Float) *FloatParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | *Float | Numeric 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).Abs(big.NewFloat(-2.5)))}