lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Why not DBL_MAX?


From: Evgeniy Tarassov
Subject: Re: [lmi] Why not DBL_MAX?
Date: Mon, 26 Mar 2007 12:05:04 +0200

On 3/24/07, Greg Chicares <address@hidden> wrote:
20070316T1310Z_DBL_MAX_to_static_limit_maximum.patch
[...]
makes good sense. But why use this:
    double stratified_entity::limit_maximum = DBL_MAX;
instead of just writing DBL_MAX?

Only to simplify the code. So that the same constant is named the same
way everywhere it is used. And of course only where it has the same
semantics.

Is there some arcane reason, e.g., that this quantity:
    static double const max_double = std::numeric_limits<double>::max();
in a removed line might not equal DBL_MAX for some woeful
compiler? (Really old versions of MinGW gcc did have an
incorrect value for DBL_EPSILON.)

I don't know, but using the same value (DBL_MAX or
stratified_entity::limit_maximum), it ensures that the program will
not produce bogus output for such a compiler.

Is the reason that the value might change someday? If so,
why? So that we could make the algorithms that use it
correct even for infinity? Or so that we could restrict
them to "plausible" values, recognizing that we're really
operating on currency and no one has even 1e37 dollars?

Two reasons for me to introduce such a constant was:
1) to make understanding and grepping the source code easier. If
additionally we introduce another static double in 'sigfpe.cpp' then
by grepping 'limit_maximum' one will only find occurences of this
constant for cases where it is used for stratified_entity limit array
values 'terminator'. When one sees DBL_MAX it only says the exact
value, not the real meaning of the constant in the local context.
2) to get rid of the repeating line
#include <cfloat> // DBL_MAX

--
With best wishes,
Evgeniy Tarassov




reply via email to

[Prev in Thread] Current Thread [Next in Thread]