Arithmetic/Integer: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: update obsoleted explainer)
Line 4,418: Line 4,418:
=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)

{{works with|Rakudo|2015.09}}
Note that <code>div</code> <b>requires</b> integer arguments. If you want integer division with other types, say <code>floor($a/$b)</code>.
<lang perl6>my Int $a = get.floor;
<lang perl6>my Int $a = get.floor;
my Int $b = get.floor;
my Int $b = get.floor;
Line 4,428: Line 4,429:
say 'remainder: ', $a % $b;
say 'remainder: ', $a % $b;
say 'exponentiation: ', $a**$b;</lang>
say 'exponentiation: ', $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|Raven}}==
=={{header|Raven}}==