/div.patch Secret
Created
February 26, 2017 15:40
Revisions
-
MasterDuke17 created this gist
Feb 26, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ diff --git a/src/core/Int.pm b/src/core/Int.pm index 34e04ea54..6f0907bdd 100644 --- a/src/core/Int.pm +++ b/src/core/Int.pm @@ -263,9 +263,18 @@ multi sub infix:<*>(int $a, int $b) returns int { } multi sub infix:<div>(Int:D \a, Int:D \b) { - b - ?? nqp::div_I(nqp::decont(a), nqp::decont(b), Int) - !! Failure.new(X::Numeric::DivideByZero.new(:using<div>, :numerator(a))) + nqp::if( + b, + nqp::if( + nqp::isbig_I(nqp::decont(a)) || nqp::isbig_I(nqp::decont(b)), + nqp::div_I(nqp::decont(a),nqp::decont(b),Int), + nqp::div_i(nqp::decont(a), nqp::decont(b)) + ), + Failure.new(X::Numeric::DivideByZero.new(:using<div>, :numerator(a))) + ) +# b +# ?? nqp::div_I(nqp::decont(a), nqp::decont(b), Int) +# !! Failure.new(X::Numeric::DivideByZero.new(:using<div>, :numerator(a))) } multi sub infix:<div>(int $a, int $b) returns int { # relies on opcode or hardware to detect division by 0