Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
11
func
Abs(n int) int {
12
if
n < 0 {
13
return
-n
14
}
15
return
n
16
}
Callers
2
TestAbs
Function · 0.70
BenchmarkSimpleAbs
Function · 0.70
Calls
no outgoing calls
Tested by
2
TestAbs
Function · 0.56
BenchmarkSimpleAbs
Function · 0.56