|
|
|
@ -106,6 +106,9 @@ impl Value {
|
|
|
|
|
(Self::Rational(x), Self::Integer(y)) => Self::rational(x / f64::from(*y)), |
|
|
|
|
|
|
|
|
|
(Self::BigInt(ref a), Self::BigInt(ref b)) => { |
|
|
|
|
if *b.as_inner() == BigInt::from(0) { |
|
|
|
|
return ctx.throw_range_error("BigInt division by zero"); |
|
|
|
|
} |
|
|
|
|
Self::bigint(a.as_inner().clone() / b.as_inner().clone()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -113,6 +116,9 @@ impl Value {
|
|
|
|
|
(_, _) => match (self.to_numeric(ctx)?, other.to_numeric(ctx)?) { |
|
|
|
|
(Numeric::Number(a), Numeric::Number(b)) => Self::rational(a / b), |
|
|
|
|
(Numeric::BigInt(ref a), Numeric::BigInt(ref b)) => { |
|
|
|
|
if *b.as_inner() == BigInt::from(0) { |
|
|
|
|
return ctx.throw_range_error("BigInt division by zero"); |
|
|
|
|
} |
|
|
|
|
Self::bigint(a.as_inner().clone() / b.as_inner().clone()) |
|
|
|
|
} |
|
|
|
|
(_, _) => { |
|
|
|
|