Arithmetic/Integer: Difference between revisions
Content added Content deleted
Line 888: | Line 888: | ||
=={{header|NSIS}}== |
=={{header|NSIS}}== |
||
All Arithmetic in NSIS is handled by the [http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.10.2 IntOp] instruction |
All Arithmetic in NSIS is handled by the [http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.10.2 IntOp] instruction. It is beyond the scope of this task to implement user input (a fairly involved task), so I will be providing hard-coded values simulating the user input, with the intention of later adding the user-input piece. |
||
<lang NSIS> |
<lang NSIS> |
||
Function Arithmetic |
|||
⚫ | |||
Push $0 |
|||
⚫ | |||
Push $1 |
|||
⚫ | |||
Push $2 |
|||
StrCpy $0 21 |
|||
StrCpy $1 -2 |
|||
⚫ | |||
DetailPrint "$0 + $1 = $2" |
|||
IntOp $2 $0 - $1 |
|||
DetailPrint "$0 - $1 = $2" |
|||
⚫ | |||
DetailPrint "$0 * $1 = $2" |
|||
⚫ | |||
DetailPrint "$0 / $1 = $2" |
|||
DetailPrint "Rounding is toward negative infinity" |
|||
IntOp $2 $0 % $1 |
|||
DetailPrint "$0 % $1 = $2" |
|||
DetailPrint "Sign of remainder matches the first number" |
|||
Pop $2 |
|||
Pop $1 |
|||
Pop $0 |
|||
FunctionEnd |
|||
</lang> |
</lang> |
||