[Numpy-tickets] [NumPy] #582: Crash when embedded using Borland Builder 6
NumPy
numpy-tickets@scipy....
Thu Sep 20 08:24:45 CDT 2007
#582: Crash when embedded using Borland Builder 6
------------------------+---------------------------------------------------
Reporter: thomas | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone:
Component: numpy.core | Version: none
Severity: major | Keywords:
------------------------+---------------------------------------------------
Hi,
when used in an embedded scenario with some non-g++ compilers, every call
of "import numpy" leads to a crash (Floating Point Overflow) because of
the following function in umathmodule.c:
static double
pinf_init(void)
{
double mul = 1e10;
double tmp = 0.0;
double pinf;
pinf = mul;
for (;;) {
pinf *= mul;
if (pinf == tmp) break;
tmp = pinf;
}
return pinf;
}
When pinf supercedes 1E300, g++ will turn it to infinity, whereas other
compilers (e.g. Borland C++ Builder) will throw an overflow exception.
My recommendation is to directly generate the double value for infinity by
IEEE 754 specification:
char inf_string[9] = "\x00\x00\x00\x00\x00\x00\xF0\x7F";
double pinf = ((double*)inf_string)[0];
on little endian architectures, and
char inf_string[9] = "\x7F\xF0\x00\x00\x00\x00\x00\x00";
double pinf = ((double*)inf_string)[0];
on big endian architectures.
Thank you!
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/582>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list