[CoinUtils] COIN_C_FINITE and DBL_MAX (CoinFinite.cpp)

Ted Ralphs ted at lehigh.edu
Sat Sep 26 13:22:37 EDT 2015


Hey Matt,

DBL_MAX is a standard symbol in C/C++, defined in the headers <cfloat> and
<float.h> (included above, that's where the definition comes from). In C++,
you can include the header file <limits> and get the same value with

std::numeric_limits<double>::max

This is cleaner and returns the precise floating point value of the largest
representable double value, whereas DBL_MAX is a macro that returns some
sort of string representation. In most cases, though, they should give the
identical result (there are strange exceptions, see http://goo.gl/6qca25).

Looking at this header file, it looks like we tried to eliminate the use of
DBL_MAX, but didn't quite finish the job :). I think you're right that it
would be better to use COIN_DBL_MAX here, but I'm always hesitant to make
these seemingly inconsequential changes when things are working :). I might
go ahead and commit this to trunk and see if anything breaks.

Cheers,

Ted

On Thu, Sep 24, 2015 at 2:32 PM, Matthew Galati <matthew.galati at gmail.com>
wrote:

> If COIN_C_FINITE is not defined, I don't see where DBL_MAX is defined.
>
> Should this be using COIN_DBL_MAX instead?
>
> bool CoinFinite(double val)
> {
> #ifdef COIN_C_FINITE
>     return COIN_C_FINITE(val)!=0;
> #else
>     return val != DBL_MAX && val != -DBL_MAX;
> #endif
> }
>
> _______________________________________________
> CoinUtils mailing list
> CoinUtils at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coinutils
>
>


-- 
Dr. Ted Ralphs
Professor, Lehigh University
(610) 628-1280
ted 'at' lehigh 'dot' edu
coral.ie.lehigh.edu/~ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/coinutils/attachments/20150926/2c315413/attachment.html>


More information about the CoinUtils mailing list