Arithmetic/Integer: Difference between revisions

Line 888:
 
=={{header|NSIS}}==
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>
Function Arithmetic
IntOp $0 1 + 3
Push $0
IntOp $1 $0 * 2
Push $1
IntOp $2 $1 / 4
Push $2
StrCpy $0 21
StrCpy $1 -2
IntOp $2 $0 1 + 3$1
DetailPrint "$0 + $1 = $2"
IntOp $2 $0 - $1
DetailPrint "$0 - $1 = $2"
IntOp $12 $0 * 2$1
DetailPrint "$0 * $1 = $2"
IntOp $2 $10 / 4$1
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>
 
Anonymous user