Abs: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
{{PageAuthor|Lloigor}} | {{PageAuthor|Lloigor}} | ||
A very simple macro to get an integer's absolute value | 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]] |