MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / Abs

Function Abs

math/abs.go:11–16  ·  view source on GitHub ↗

Abs returns absolute value

(n int)

Source from the content-addressed store, hash-verified

9
10// Abs returns absolute value
11func Abs(n int) int {
12 if n < 0 {
13 return -n
14 }
15 return n
16}

Callers 2

TestAbsFunction · 0.70
BenchmarkSimpleAbsFunction · 0.70

Calls

no outgoing calls

Tested by 2

TestAbsFunction · 0.56
BenchmarkSimpleAbsFunction · 0.56