mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-09-16 12:04:06 +00:00
aeb9c0668b
Note: Many files were removed (not yet existing/empty pages). The parser will try to download them on demand and will auto-generate text for missing pages (eg. most _gl pages).
40 lines
1,010 B
Text
40 lines
1,010 B
Text
{{QBDLDATE:05-20-2022}}
|
|
{{QBDLTIME:23:11:40}}
|
|
The [[ABS]] function returns the unsigned numerical value of a variable or literal value.
|
|
|
|
|
|
{{PageSyntax}}
|
|
:{{Parameter|positive}} = [[ABS]]({{Parameter|numericalValue}})
|
|
|
|
|
|
{{PageDescription}}
|
|
* [[ABS]] always returns positive numerical values. The value can be any numerical type.
|
|
* Often used to keep a value positive when necessary in a program.
|
|
* 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.
|
|
|
|
|
|
{{PageExamples}}
|
|
''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]]
|
|
* [[_UNSIGNED]]
|
|
* [[_DEFINE]]
|
|
* [[Mathematical Operations]]
|
|
|
|
|
|
{{PageNavigation}}
|
|
|