Arithmetic/Integer: Difference between revisions

Added Perl 6.
No edit summary
(Added Perl 6.)
Line 657:
"exponent: ", $a ** $b, "\n"
;</lang>
 
=={{header|Perl 6}}==
{{works with|Rakudo|#21 "Seattle"}}
 
<lang perl6>my Int $a = floor $*IN.get;
my Int $b = floor $*IN.get;
 
say 'sum: ', $a + $b;
say 'difference: ', $a - $b;
say 'product: ', $a * $b;
say 'integer quotient: ', $a div $b;
say 'remainder: ', $a % $b;
say 'exponentation: ', $a**$b;</lang>
 
Note that <code>div</code> doesn't always do integer division; it performs the operation "most appropriate to the
operand types". [http://perlcabal.org/syn/S03.html#line_729 Synopsis 3] guarantees that <code>div</code> "on built-in integer types is equivalent to taking the floor of a real division". If you want integer division with other types, say <code>floor($a/$b)</code>.
 
=={{header|PHP}}==
845

edits