We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 571a578 commit e8e044bCopy full SHA for e8e044b
maths/abs.nim
@@ -8,8 +8,9 @@ runnableExamples:
8
doAssert absMax(@[-1, 2, -3]) == 3
9
doAssert absMaxSort(@[3, -10, -2]) == -10
10
11
-func absVal(num: float): float =
12
- ## Returns the absolute value of a number.
+func absVal[T: SomeFloat](num: T): T =
+## Returns the absolute value of a number.
13
+## Use `math.abs <https://nim-lang.org/docs/system.html#abs%2CT>`_ instead!
14
return if num < 0.0: -num else: num
15
16
# Same for integers but return a Natural
0 commit comments