Arithmetic/Integer: Difference between revisions

Added Mathcad example.
(→‎{{header|Wren}}: Added notes, prompts, exponentiation, sample output and syntax highlighting.)
(Added Mathcad example.)
Line 2,852:
remainder: 2
exponentiation: 4913</pre>
 
=={{header|Mathcad}}==
'''Task Notes'''
 
''For quotient, indicate how it rounds (e.g. towards zero, towards negative infinity, etc.).''
 
There is no quotient function in Mathcad, only complex division. We emulate quotient by standard division followed by rounding using both floor, which rounds towards negative infinity, and trunc, which rounds towards zero.
 
''For remainder, indicate whether its sign matches the sign of the first operand or of the second operand, if they are different.
''
We use the Mathcad function mod(x,y), which returns x modulo y, and has the same sign as x.
 
'''Instructions'''
 
Enter two integers of your choice for Int1 and Int2.
 
(type into the right hand side of the 'Int1:= ' and 'Int2:=' statements, overwriting or modifying any numbers already there)
 
'''Implementation'''
 
'''Mathcad Input and Output'''
 
Mathcad "standard" input and output takes place directly on a worksheet ("program source code").
 
'''Inputs''':
 
== ''the user types in values after := (definition) operator''
 
Integer One: ''Int1'':='''-8'''
 
Integer Two: ''Int2'':='''3'''
 
'''Results''':
 
== ''Mathcad automatically calculates and displays results after = (evaluation) operator.''
 
sum : ''Int1'' + ''Int2'' = -5
 
difference : ''Int1'' - ''Int2'' = -11
 
product : ''Int1'' · ''Int2'' = -24
 
integer quotient : floor(''Int1''÷''Int2'')=-3 trunc(Int1÷Int2)=-2
 
remainder : mod(''Int1'',''Int2'')=-2
 
exponentiation : ''Int1''<sup>''Int2''</sup>=-512
 
=={{header|MATLAB}} / {{header|Octave}}==