Abs: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(abs) |
m (Reverted edits by 199.48.147.37 to last version by Lloigor) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{PageAuthor|Lloigor}} | {{PageAuthor|Lloigor}} | ||
A very simple macro to get an integer's absolute value. | |||
<highlight-nsis> | <highlight-nsis>!define Abs "!insertmacro _Abs" | ||
!macro _Abs _RetVal_ _Value_ | |||
IntOp ${_RetVal_} ${_Value_} & 0x7FFFFFFFFFFFFFFF | |||
!define Abs "!insertmacro _Abs" | |||
!macro _Abs _Value_ | |||
IntOp ${ | |||
!macroend</highlight-nsis> | !macroend</highlight-nsis> | ||
Usage:<highlight-nsis> | Usage:<highlight-nsis>StrCpy $0 -40 | ||
${ABS} $ | ${ABS} $0 $0 ; $0 = 40</highlight-nsis> | ||
[[Category:Math Functions]] | [[Category:Math Functions]] |