1 |
<html> |
2 |
<head> |
3 |
<meta name="author" content="Christian Schoenebeck"> |
4 |
<title>abs() function</title> |
5 |
<meta name="description" content="Calculates the absolute value of a given value."> |
6 |
</head> |
7 |
<body> |
8 |
<h1>abs()</h1> |
9 |
<p> |
10 |
Returns the absolute value of the passed value argument. That means, if a |
11 |
positive number or zero is passed, then the same number is returned. |
12 |
If however a negative number is passed, then the signment of the number |
13 |
is flipped to positive. So it behaves like simply removing the minus |
14 |
sign if any. |
15 |
</p> |
16 |
|
17 |
<h3>Function Prototype</h3> |
18 |
<p/> |
19 |
<code lang="nksp"> |
20 |
abs(??number??) |
21 |
</code> |
22 |
|
23 |
<h3>Arguments</h3> |
24 |
<table> |
25 |
<tr> |
26 |
<th>Argument Name</th> <th>Data Type</th> <th>Description</th> |
27 |
</tr> |
28 |
<tr> |
29 |
<td><code>??number??</code></td> |
30 |
<td>Integer Number</td> |
31 |
<td>The number to convert.<br> |
32 |
[required]</td> |
33 |
</tr> |
34 |
</table> |
35 |
|
36 |
<h3>Return Value</h3> |
37 |
<table> |
38 |
<tr> |
39 |
<th>Description</th> <th>Data Type</th> |
40 |
</tr> |
41 |
<tr> |
42 |
<td>Absolute value of the passed number.</td> |
43 |
<td>Integer Number</td> |
44 |
</tr> |
45 |
</table> |
46 |
|
47 |
<h3>Examples</h3> |
48 |
<p/> |
49 |
<code> |
50 |
on init |
51 |
declare %values[7] := ( -3, -2, -1, 0, 1, 2, 3 ) |
52 |
declare $i := 0 |
53 |
while ($i < num_elements(values)) |
54 |
message("The absolute value of " & $values[$i] & " is " & abs($values[$i])) |
55 |
end while |
56 |
end on |
57 |
</code> |
58 |
|
59 |
</body> |
60 |
</html> |