absolutevalue: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
m (Replaced source tages with syntaxhighlight)
Line 5: Line 5:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: val = absolutevalue(num)]
[h: val = absolutevalue(num)]
</source>
</syntaxhighlight>
You can use the following shorthand for this function:
You can use the following shorthand for this function:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: val = abs(num)]
[h: val = abs(num)]
</source>
</syntaxhighlight>


|examples=
|examples=
====Negative Number====
====Negative Number====
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: absolutevalue(-3)]
[r: absolutevalue(-3)]
</source>
</syntaxhighlight>
Returns:<source lang="mtmacro" line start=2>3</source>
Returns:<syntaxhighlight lang="mtmacro" line start=2>3</syntaxhighlight>




====Positive Number====
====Positive Number====
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: abs(4)]
[r: abs(4)]
</source>
</syntaxhighlight>
Returns:<source lang="mtmacro" line start=2>4</source>
Returns:<syntaxhighlight lang="mtmacro" line start=2>4</syntaxhighlight>




====Decimal Number====
====Decimal Number====
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: abs(3.4)]
[r: abs(3.4)]
</source>
</syntaxhighlight>
Returns:<source lang="mtmacro" line start=2>3.4</source>
Returns:<syntaxhighlight lang="mtmacro" line start=2>3.4</syntaxhighlight>


}}
}}
[[Category:Mathematical Function]]
[[Category:Mathematical Function]]
{{Languages|absolutevalue}}
{{Languages|absolutevalue}}

Revision as of 18:02, 14 July 2022

Languages:  English  • 日本語  • 한국어


absolutevalue() Function

Returns the absolute value of a number. The absolute value of a number is the number without the sign.

Usage

[h: val = absolutevalue(num)]

You can use the following shorthand for this function:

[h: val = abs(num)]

Examples

====Negative Number====
[r: absolutevalue(-3)]
Returns:
3


Positive Number

[r: abs(4)]
Returns:
4


Decimal Number

[r: abs(3.4)]
Returns:
3.4

Languages:  English  • 日本語  • 한국어