2020-01-20 02:36:46 +00:00
|
|
|
The [[ABS]] function returns the unsigned numerical value of a variable or literal value.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
{{PageSyntax}}
|
2017-10-10 14:55:21 +00:00
|
|
|
:{{Parameter|positive}} = [[ABS]]({{Parameter|numericalValue}})
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
{{PageDescription}}
|
2017-10-10 14:55:21 +00:00
|
|
|
* [[ABS]] always returns positive numerical values. The value can be any numerical type.
|
2015-08-02 12:12:44 +00:00
|
|
|
* Often used to keep a value positive when necessary in a program.
|
2017-10-10 14:55:21 +00:00
|
|
|
* Use [[SGN]] to determine a value's sign when necessary.
|
|
|
|
* '''QB64''' allows programs to return only positive [[_UNSIGNED]] variable values using a [[DIM]] or [[_DEFINE]] statement.
|
2015-08-02 12:12:44 +00:00
|
|
|
|
|
|
|
|
2017-10-10 14:55:21 +00:00
|
|
|
{{PageExamples}}
|
2015-08-02 12:12:44 +00:00
|
|
|
''Example:'' Finding the absolute value of positive and negative numerical values.
|
|
|
|
{{CodeStart}} '' ''
|
|
|
|
a = -6
|
|
|
|
b = -7
|
|
|
|
c = 8
|
|
|
|
{{Cl|IF...THEN|IF}} a < 0 {{Cl|THEN}} a = {{Cl|ABS}}(a)
|
|
|
|
b = {{Cl|ABS}}(b)
|
|
|
|
c = {{Cl|ABS}}(c)
|
|
|
|
{{Cl|PRINT}} a, b, c '' ''
|
|
|
|
{{CodeEnd}}
|
|
|
|
{{OutputStart}} 6 7 8
|
|
|
|
{{OutputEnd}}
|
|
|
|
|
|
|
|
|
|
|
|
{{PageSeeAlso}}
|
|
|
|
* [[SGN]], [[DIM]]
|
2017-10-10 14:55:21 +00:00
|
|
|
* [[_UNSIGNED]]
|
2015-08-02 12:12:44 +00:00
|
|
|
* [[_DEFINE]]
|
|
|
|
* [[Mathematical Operations]]
|
|
|
|
|
|
|
|
|
2019-04-15 01:15:33 +00:00
|
|
|
{{PageNavigation}}
|