"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core.c/Int.pm6" between
rakudo-2020.09.tar.gz and rakudo-2020.10.tar.gz

About: Rakudo is a compiler for the Raku Pogramming Language (formerly known as Perl 6).

Int.pm6  (rakudo-2020.09):Int.pm6  (rakudo-2020.10)
skipping to change at line 160 skipping to change at line 160
$more = $more div $mod; $more = $more div $mod;
} }
take $more; take $more;
} }
} }
} }
method expmod(Int:D: Int:D \base, Int:D \mod --> Int:D) { method expmod(Int:D: Int:D \base, Int:D \mod --> Int:D) {
nqp::expmod_I(self, nqp::decont(base), nqp::decont(mod), Int); nqp::expmod_I(self, nqp::decont(base), nqp::decont(mod), Int);
} }
method is-prime(--> Bool:D) { nqp::hllbool(nqp::isprime_I(self,100)) } method is-prime(--> Bool:D) { nqp::hllbool(nqp::isprime_I(self)) }
method floor(Int:D:) { self } method floor(Int:D:) { self }
method ceiling(Int:D:) { self } method ceiling(Int:D:) { self }
proto method round(|) {*} proto method round(|) {*}
multi method round(Int:D:) { self } multi method round(Int:D:) { self }
multi method round(Int:D: Real(Cool) $scale --> Real:D) { multi method round(Int:D: Real(Cool) $scale --> Real:D) {
(self / $scale + 1/2).floor * $scale (self / $scale + 1/2).floor * $scale
} }
method lsb(Int:D: --> Int:D) { method lsb(Int:D: --> Int:D) {
skipping to change at line 398 skipping to change at line 398
), ),
Failure.new(X::Numeric::DivideByZero.new(:using<%>, :numerator(a))) Failure.new(X::Numeric::DivideByZero.new(:using<%>, :numerator(a)))
) )
) )
} }
multi sub infix:<%>(int $a, int $b --> int) { multi sub infix:<%>(int $a, int $b --> int) {
# relies on opcode or hardware to detect division by 0 # relies on opcode or hardware to detect division by 0
nqp::mod_i(nqp::add_i(nqp::mod_i($a,$b),$b),$b) # quick fix https://github.c om/Raku/old-issue-tracker/issues/4999 nqp::mod_i(nqp::add_i(nqp::mod_i($a,$b),$b),$b) # quick fix https://github.c om/Raku/old-issue-tracker/issues/4999
} }
multi sub infix:<%%>(Int:D \a, Int:D \b) {
nqp::if(
nqp::isbig_I(nqp::decont(a)) || nqp::isbig_I(nqp::decont(b)),
nqp::if(
b,
!nqp::mod_I(nqp::decont(a),nqp::decont(b),Int),
Failure.new(
X::Numeric::DivideByZero.new(using => 'infix:<%%>', numerator => a)
)
),
nqp::if(
nqp::isne_i(b,0),
nqp::hllbool(nqp::not_i(nqp::mod_i(nqp::decont(a),nqp::decont(b)))),
Failure.new(
X::Numeric::DivideByZero.new(using => 'infix:<%%>', numerator => a)
)
)
)
}
multi sub infix:<%%>(int $a, int $b --> Bool:D) { multi sub infix:<%%>(int $a, int $b --> Bool:D) {
nqp::hllbool(nqp::iseq_i(nqp::mod_i($a, $b), 0)) nqp::hllbool(nqp::iseq_i(nqp::mod_i($a, $b), 0))
} }
multi sub infix:<**>(Int:D \a, Int:D \b --> Real:D) { multi sub infix:<**>(Int:D \a, Int:D \b --> Real:D) {
my $power := nqp::pow_I(nqp::decont(a), nqp::decont(b >= 0 ?? b !! -b), Num, Int); my $power := nqp::pow_I(nqp::decont(a), nqp::decont(b >= 0 ?? b !! -b), Num, Int);
# when a**b is too big nqp::pow_I returns Inf # when a**b is too big nqp::pow_I returns Inf
nqp::istype($power, Num) nqp::istype($power, Num)
?? Failure.new( ?? Failure.new(
b >= 0 ?? X::Numeric::Overflow.new !! X::Numeric::Underflow.new b >= 0 ?? X::Numeric::Overflow.new !! X::Numeric::Underflow.new
) !! b >= 0 ?? $power ) !! b >= 0 ?? $power
!! ($power := 1 / $power) == 0 && a != 0 !! ($power := 1 / $power) == 0 && a != 0
?? Failure.new(X::Numeric::Underflow.new) ?? Failure.new(X::Numeric::Underflow.new)
!! $power; !! $power;
} }
multi sub infix:<**>(int $a, int $b --> int) { multi sub infix:<**>(int $a, int $b --> int) {
nqp::pow_i($a, $b); nqp::pow_i($a, $b);
} }
multi sub infix:<lcm>(Int:D $x = 1) { $x }
multi sub infix:<lcm>(Int:D \a, Int:D \b --> Int:D) { multi sub infix:<lcm>(Int:D \a, Int:D \b --> Int:D) {
nqp::lcm_I(nqp::decont(a), nqp::decont(b), Int); nqp::lcm_I(nqp::decont(a), nqp::decont(b), Int);
} }
multi sub infix:<lcm>(int $a, int $b --> int) { multi sub infix:<lcm>(int $a, int $b --> int) {
nqp::lcm_i($a, $b) nqp::lcm_i($a, $b)
} }
multi sub infix:<gcd>(Int:D $x) { $x }
multi sub infix:<gcd>(Int:D \a, Int:D \b --> Int:D) { multi sub infix:<gcd>(Int:D \a, Int:D \b --> Int:D) {
nqp::gcd_I(nqp::decont(a), nqp::decont(b), Int); nqp::gcd_I(nqp::decont(a), nqp::decont(b), Int);
} }
multi sub infix:<gcd>(int $a, int $b --> int) { multi sub infix:<gcd>(int $a, int $b --> int) {
nqp::gcd_i($a, $b) nqp::gcd_i($a, $b)
} }
multi sub infix:<===>(Int:D $a, Int:D $b --> Bool:D) { multi sub infix:<===>(Int:D $a, Int:D $b --> Bool:D) {
nqp::hllbool( nqp::hllbool(
nqp::eqaddr($a.WHAT,$b.WHAT) nqp::eqaddr($a.WHAT,$b.WHAT)
 End of changes. 4 change blocks. 
1 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)