Closed robertnishihara closed 8 years ago
The problem is not in the Python C extensions. For example, defining a simple function
static PyObject* convert_float(PyObject* self, PyObject* args) {
PyObject* obj;
if (!PyArg_ParseTuple(args, "O", &obj)) {
return NULL;
}
double d = PyFloat_AsDouble(obj);
return PyFloat_FromDouble(d);
}
And calling convert_float
preserves the value.
Note the following.
import numpy as np
float(np.float32(0.9)) # prints 0.8999999761581421
This is addressed by #435.