Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created February 26, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/5d63c32bae0c719df31370b78bc65c66 to your computer and use it in GitHub Desktop.
Save MasterDuke17/5d63c32bae0c719df31370b78bc65c66 to your computer and use it in GitHub Desktop.
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