Skip to content

Commit

Permalink
Fix ATAN.ERROR.5
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Sep 3, 2024
1 parent 4234ba0 commit 90a6190
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
14 changes: 14 additions & 0 deletions include/clasp/core/float_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ template <typename Float> struct float_convert {

return from_bits(b);
};

template <std::integral Integral> static Float from_integral(Integral i) {
quadruple q = {.category = category::finite, .sign = (i < 0) ? -1 : 1};
i = std::abs(i);
int32_t shift = std::bit_width(i) - std::bit_width(std::numeric_limits<uint_t>::max);
if (shift > 0) {
q.significand = i >> shift;
q.exponent = shift;
} else {
q.significand = i;
}

return from_quadruple(q);
}
};

} // namespace core
10 changes: 5 additions & 5 deletions include/clasp/core/numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -927,11 +927,11 @@ CL_DEFUN inline Number_sp clasp_signum(Number_sp num) {
return make_number(-1);
} else if (num.single_floatp()) {
float fl = num.unsafe_single_float();
if (fl == 0.0)
return make_number(0.0);
if (fl < 0.0)
return make_number(-1.0);
return make_number(1.0);
if (fl == 0.0f)
return make_number(0.0f);
if (fl < 0.0f)
return make_number(-1.0f);
return make_number(1.0f);
}
return num->signum_();
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/numbers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2489,13 +2489,13 @@ Number_sp Number_O::atan(Number_sp y) {
}
}

CL_LAMBDA(x &optional y);
CL_LAMBDA(x &optional (y nil yp));
CL_DECLARE();
CL_UNWIND_COOP(true);
CL_DOCSTRING(R"dx(atan)dx");
DOCGROUP(clasp);
CL_DEFUN Number_sp cl__atan(Number_sp x, T_sp y) {
if (y.nilp())
CL_DEFUN Number_sp cl__atan(Number_sp x, T_sp y, bool yp) {
if (!yp)
return Number_O::atan(x);

if (gctools::IsA<Number_sp>(y))
Expand Down
1 change: 0 additions & 1 deletion tools-for-build/ansi-test-expected-failures.sexp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ CALL-NEXT-METHOD.ERROR.2
DEFMETHOD.ERROR.14
DEFMETHOD.ERROR.15
UPGRADED-ARRAY-ELEMENT-TYPE.8
ATAN.ERROR.5
MAP.ERROR.11
TYPE-OF.1
TYPE-OF.4
Expand Down

0 comments on commit 90a6190

Please sign in to comment.