Re: a simple question

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/a-simple-question-tp9462p9467.html

On Fri, 2007-05-18 at 10:08 +0200, DU VIGNAUD DE VILLEFORT FRANCOIS
GASAPRD PHI wrote:
> Is there any reason why QL_NULL_REAL  is defined this way :
>
> #define QL_NULL_REAL   ((std::numeric_limits<float>::max)())
>
> whereas QL_MIN_REAL and QL_MAX_REAL  are defined this way :
>
> #define QL_MAX_REAL   ((std::numeric_limits<QL_REAL>::max)())


In theory, QL_REAL might be redefined to float or long double (in
practice it is not, as some tests break.) QL_MIN_REAL and QL_MAX_REAL
should be the min and max value for the actual type chosen, so
numeric_limits<QL_REAL> is used. As for QL_NULL_REAL, it doesn't really
matter what value is used as long as it's a determined one, so there's
no need to use the actual QL_REAL type; also, we define Null<float>,
Null<double> and Null<long double> to be all equal to QL_NULL_REAL,
which is somewhat convenient (this way, Null<T> is the same number, no
matter the actual type) and using float ensured that the resulting
number could be contained in all such types without overflow.

Speaking of which, funny that you came out with a question on Null. Just
yesterday I was thinking of removing it and using boost::optional when a
number might or might not be defined. What do you think?

Later,
        Luigi


----------------------------------------

Lubarsky's Law of Cybernetic Entomology:
There is _always_ one more bug.



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev