correct float version of sign/1 (#1360)
This commit is contained in:
@@ -82,16 +82,6 @@ fn numerical_type_error(
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn sign(n: Number) -> Number {
|
||||
if n.is_positive() {
|
||||
Number::Fixnum(Fixnum::build_with(1))
|
||||
} else if n.is_negative() {
|
||||
Number::Fixnum(Fixnum::build_with(-1))
|
||||
} else {
|
||||
Number::Fixnum(Fixnum::build_with(0))
|
||||
}
|
||||
}
|
||||
|
||||
fn isize_gcd(n1: isize, n2: isize) -> Option<isize> {
|
||||
if n1 == 0 {
|
||||
return n2.checked_abs().map(|n| n as isize);
|
||||
@@ -1278,7 +1268,7 @@ impl MachineState {
|
||||
atom!("\\") => self.interms.push(
|
||||
drop_iter_on_err!(self, iter, bitwise_complement(a1, &mut self.arena))
|
||||
),
|
||||
atom!("sign") => self.interms.push(sign(a1)),
|
||||
atom!("sign") => self.interms.push(a1.sign()),
|
||||
_ => {
|
||||
let evaluable_stub = functor_stub(name, 1);
|
||||
std::mem::drop(iter);
|
||||
|
||||
@@ -714,7 +714,7 @@ impl Machine {
|
||||
&Instruction::Sign(ref a1, t) => {
|
||||
let n = try_or_throw!(self.machine_st, self.machine_st.get_number(a1));
|
||||
|
||||
self.machine_st.interms[t - 1] = sign(n);
|
||||
self.machine_st.interms[t - 1] = n.sign();
|
||||
self.machine_st.p += 1;
|
||||
}
|
||||
&Instruction::Neg(ref a1, t) => {
|
||||
|
||||
@@ -2594,15 +2594,6 @@ impl MachineState {
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
pub fn setup_built_in_call(&mut self, ct: BuiltInClauseType) {
|
||||
self.num_of_args = ct.arity();
|
||||
self.b0 = self.b;
|
||||
|
||||
self.p = CodePtr::BuiltInClause(ct, self.p.local());
|
||||
}
|
||||
*/
|
||||
|
||||
pub fn deallocate(&mut self) {
|
||||
let e = self.e;
|
||||
let frame = self.stack.index_and_frame(e);
|
||||
|
||||
Reference in New Issue
Block a user