Returns the absolute value. The return-value is always positive.
Why a negative result?
Code: Select all
z.l=Abs($80000000)
Debug z
Returns the absolute value. The return-value is always positive.
Code: Select all
z.l=Abs($80000000)
Debug zThe number from which to get the absolute value. This function will only work correctly with float numbers. With integers, it will fail if the integer is too large (due to a loss of precision).
Code: Select all
z.f=Abs($80000000)
Debug z 
Code: Select all
Macro iABS(i,ans)
If i < 0
ans = -i
Else
ans = i
EndIf
EndMacro
EnableExplicit
Define c.i = -1234, M.i, p.i, dt = ElapsedMilliseconds()
For M = 1 To 10000000
iABS(c,p)
Next M
MessageRequester("Result: " + Str(p),"In: " + Str(ElapsedMilliseconds() - dt))

Long | .l | 4 bytes | -2147483648 to +2147483647
Code: Select all
z.l = $7FFFFFFF
Debug z
z = $80000000
Debug zCode: Select all
; min. Quad: -9223372036854775808
Define.q Value = Abs(-77777777777777777)
Debug Value ; 77777777777777776Code: Select all
Define.l Value
; min. Long: -2147483648
Value = Abs(-2147483648)
Debug Value ; -2147483648 => Because Overflow
Debug Bin(Value, #PB_Long) ; 10000000000000000000000000000000
; min. Long: -2147483648
Value = Abs(-2147483647)
Debug Value ; 2147483647
Debug Bin(Value, #PB_Long) ; 1111111111111111111111111111111