Abs returns the absolute value of x.
package main import ( "fmt" "math" ) func main() { x := math.Abs(-2) fmt.Printf("%.1f\n", x) y := math.Abs(2) fmt.Printf("%.1f\n", y) }