-
-
Save MasterDuke17/5d63c32bae0c719df31370b78bc65c66 to your computer and use it in GitHub Desktop.
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 characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment