Re: special floats generate incorrect C code when used as compile-time constants
Stefan Behnel <[email protected]>
| Newsgroups | gmane.comp.python.pyrex |
|---|---|
| Message-ID | <[email protected]> |
Hi, Chris Mellon wrote: > On Tue, Apr 22, 2008 at 6:13 PM, Greg Ewing <[email protected]> wrote: >> Stefan Behnel wrote: >> > DEF INFINITY = float('inf') >> > print INFINITY >> > >> > results in: >> > >> > foo.c: In function 'init2foo': >> > foo.c:158: error: 'inf' undeclared (first use in this function) This was actually due to a bug report by Jacques Frechet: https://bugs.launchpad.net/cython/+bug/218377 >> I'm not sure whether to do anything about this for Pyrex. >> As I understand it, Python doesn't promise anything about >> representation of inf and nan, so it's platform dependent. >> I'm inclined to think that using an appropriate constant >> from your platform's math.h is the right thing to do. > > As of 2.6, float('inf') and float('nan') will be guaranteed to work > (instead of punting to libcs atof which is what it does now), so > supporting it in Pyrex is forward-looking at least ;) In Cython, a float "nan" or "inf" constant will now be translated into the C equivalents from math.h (NAN/INFINITY). Do you happen to know if that's compatible with what Python 2.6 does? Stefan