implement (div)/2 properly (#435)
This commit is contained in:
@@ -268,20 +268,10 @@ impl MachineState {
|
|||||||
|
|
||||||
pub(crate)
|
pub(crate)
|
||||||
fn int_floor_div(&self, n1: Number, n2: Number) -> Result<Number, MachineStub> {
|
fn int_floor_div(&self, n1: Number, n2: Number) -> Result<Number, MachineStub> {
|
||||||
match n1 / n2 {
|
let stub = MachineError::functor_stub(clause_name!("(div)"), 2);
|
||||||
Ok(result) => {
|
let modulus = self.modulus(n1.clone(), n2.clone())?;
|
||||||
Ok(rnd_i(&result).to_owned())
|
|
||||||
}
|
self.idiv(try_numeric_result!(self, n1 - modulus, stub)?, n2)
|
||||||
Err(e) => {
|
|
||||||
let stub = MachineError::functor_stub(clause_name!("(div)"), 2);
|
|
||||||
Err(self.error_form(
|
|
||||||
MachineError::evaluation_error(
|
|
||||||
e
|
|
||||||
),
|
|
||||||
stub
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate)
|
pub(crate)
|
||||||
|
|||||||
Reference in New Issue
Block a user