On mardi 21 mars 2017 16:11:44 CET Mateusz Loskot wrote: > On 21 March 2017 at 15:50, Kurt Schwehr <[email protected]> wrote: > > Hey Even, > > > > Probably not a big deal, but I'm curious why you didn't use !isinf(MinX) > > or > > isfinite(MinX) for your recent OGREnvelope patch: > > > > int IsInit() const { return MinX != > > std::numeric_limits<double>::infinity(); } > > Portability wank: it's also good idea to check for > std::numeric_limits<number<T> >::has_infinity > > eg. something like > > std::numeric_limits<number<double>::has_infinity > ? std::numeric_limits<number<double>::infinity() > > : (std::numeric_limits<number<double>::max)()
Looking at http://en.cppreference.com/w/cpp/types/numeric_limits/infinity, it seems that std::numeric_limits<double>::infinity always resolve to some reasonable "big" value. And looking at http://en.cppreference.com/w/cpp/types/numeric_limits/has_infinity and http://en.cppreference.com/w/cpp/types/numeric_limits/is_iec559, it might not be a specific value on some non-IEEE754 problems. Anyway we already use std::numeric_limits<double>::infinity() in a number of places. And more subtelty, we serialize/deserialize between 8 bytes stored in files and C/C++ double in a lot of places (an trust me, that's really a lot ! shapefile, WKB, geotiff, many drivers) assuming that the machine representation of double is IEEE754. So basically GDAL is only compatible of such machines. And apparently people using non-IEEE754 platforms are too shy to complain or provide compatibility patches :-) Even -- Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________ gdal-dev mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/gdal-dev
