Commit 820dd0cd authored by Marius Wachtler's avatar Marius Wachtler

Merge pull request #1236 from undingen/cleanup_float_cpp

float.cpp: now that we have float.c use some of the functions directly
parents 5ae5bf2c 11c0b2c8
......@@ -409,9 +409,7 @@ float_str(PyFloatObject *v)
* coercion to double. So this part is painful too.
*/
// Pyston change: don't need this for now
#if 0
static PyObject*
PyObject*
float_richcompare(PyObject *v, PyObject *w, int op)
{
double i, j;
......@@ -624,7 +622,6 @@ float_richcompare(PyObject *v, PyObject *w, int op)
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
#endif
static long
float_hash(PyFloatObject *v)
......@@ -1887,7 +1884,7 @@ float_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return newobj;
}
static PyObject *
PyObject *
float_getnewargs(PyFloatObject *v)
{
return Py_BuildValue("(d)", v->ob_fval);
......@@ -1902,7 +1899,7 @@ typedef enum {
static float_format_type double_format, float_format;
static float_format_type detected_double_format, detected_float_format;
static PyObject *
PyObject *
float_getformat(PyTypeObject *v, PyObject* arg)
{
char* s;
......@@ -2200,6 +2197,8 @@ PyTypeObject PyFloat_Type = {
0, /* tp_alloc */
float_new, /* tp_new */
};
// pyston change:
#endif
void
_PyFloat_Init(void)
......@@ -2255,6 +2254,8 @@ _PyFloat_Init(void)
PyStructSequence_InitType(&FloatInfoType, &floatinfo_desc);
}
// pyston change: don't need this
#if 0
int
PyFloat_ClearFreeList(void)
{
......@@ -2351,8 +2352,6 @@ PyFloat_Fini(void)
}
#endif
// pyston change: comment this out
#if 0
/*----------------------------------------------------------------------------
* _PyFloat_{Pack,Unpack}{4,8}. See floatobject.h.
*/
......@@ -2762,4 +2761,3 @@ _PyFloat_Unpack8(const unsigned char *p, int le)
return x;
}
}
#endif
......@@ -509,8 +509,10 @@ extern "C" long _Py_HashDouble(double v) noexcept {
* of mapping keys will turn out weird.
*/
// pyston change: was if (!Py_IS_FINITE(v)) {
if (!std::isfinite(v)) {
if (Py_IS_INFINITY(v))
// pyston change: was if (Py_IS_INFINITY(v)) {
if (std::isinf(v))
return v < 0 ? -271828 : 314159;
else
return 0;
......
This diff is collapsed.
......@@ -354,7 +354,7 @@ extern "C" double PyLong_AsDouble(PyObject* vv) noexcept {
mpfr_init_set_z(result, l->n, MPFR_RNDN);
double result_f = mpfr_get_d(result, MPFR_RNDN);
if (isinf(result_f)) {
if (std::isinf(result_f)) {
PyErr_SetString(PyExc_OverflowError, "long int too large to convert to float");
return -1;
}
......@@ -408,11 +408,11 @@ extern "C" PyAPI_FUNC(PyObject*) _PyLong_Format(PyObject* aa, int base, int addL
}
extern "C" PyObject* PyLong_FromDouble(double v) noexcept {
if (isnan(v)) {
if (std::isnan(v)) {
PyErr_SetString(PyExc_ValueError, "cannot convert float NaN to integer");
return NULL;
}
if (isinf(v)) {
if (std::isinf(v)) {
PyErr_SetString(PyExc_OverflowError, "cannot convert float infinity to integer");
return NULL;
}
......@@ -1408,7 +1408,7 @@ Box* longTrueDiv(BoxedLong* v1, Box* _v2) {
double result_f = mpfr_get_d(result, MPFR_RNDN);
if (isinf(result_f)) {
if (std::isinf(result_f)) {
raiseExcHelper(OverflowError, "integer division result too large for a float");
}
return boxFloat(result_f);
......@@ -1438,7 +1438,7 @@ Box* longRTrueDiv(BoxedLong* v1, Box* _v2) {
mpfr_div(result, lhs_f, rhs_f, MPFR_RNDN);
double result_f = mpfr_get_d(result, MPFR_RNDZ);
if (isinf(result_f)) {
if (std::isinf(result_f)) {
raiseExcHelper(OverflowError, "integer division result too large for a float");
}
return boxFloat(result_f);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment