Arithmetic/Integer: Difference between revisions

Content added Content deleted
(adding maxima)
(→‎{{header|REXX}}: corrected statement about the sign of the remainder, added much whitespace in program and output. -- ~~~~)
Line 1,928: Line 1,928:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX*/
<lang rexx>/*REXX pgm gets 2 integers from the console and displays various results*/
pad=left('',20) /*used for indenting the output. */
say "enter 2 integer values separated by blanks"
yields=' ───► ' /*use this to show "yields". */
parse pull a b

say a "+" b "=" a+b
say /*add a blank line to the output.*/
say a "-" b "=" a-b
say "Enter two integer values (separated by blanks):"
say a "*" b "=" a*b

say a "/" b "=" a%b "remaining" a//b "(sign from first operand)"
parse pull a b . /*or, could use: PULL A B . */
say a "^" b "=" a**b</lang>

say /*add a blank line to the output.*/
say pad a " + " b yields a+b
say pad a " - " b yields a-b
say pad a " * " b yields a*b
say pad a " / " b yields a%b "remaining" a//b "(sign from 2nd operand)"
say pad a "** " b yields a**b</lang>
'''output'''
'''output'''
<pre>
<pre>enter 2 integer values separated by blanks
Enter two integer values (separated by blanks):
17 -4
17 -4

17 + -4 = 13
17 + -4 ───► 13
17 - -4 = 21
17 - -4 ───► 21
17 * -4 = -68
17 * -4 ───► -68
17 / -4 = -4 remaining 1 (sign from first operand)
17 / -4 ───► -4 remaining 1 (sign from 2nd operand)
17 ^ -4 = 0.0000119730367</pre>
17 ** -4 ───► 0.0000119730367
</pre>


=={{header|Ruby}}==
=={{header|Ruby}}==