
Boost : 
From: Christoph Ludwig (cludwig_at_[hidden])
Date: 20051203 11:38:23
On Fri, Dec 02, 2005 at 07:45:02PM 0000, John Maddock wrote:
> On Darwin numeric_limits<>::epsilon returns something like 10^303 which is
> the same as the value for numeric_limts<>::min() I believe. It's just plain
> crazy, all IMO of course :)
I tend to agree Darwin's choice of numeric_limits<long double>::epsilon is
wrong; it is certainly likely to cause problems for numerical code.
I think I see where this value comes from, though: According to section
18.2.1.2/20 of the C++ standard, numeric_limits<T>::epsilon() is
Machine epsilon: the difference between 1 and the least value greater than 1
that is representable.
The value of a long double ld on Darwin is, according to Geoffrey Keating's
explanation in the GCC tree <url:http://tinyurl.com/9thr3>, the sum of two
double; let's call them hi and low. If hi == 1.0 and low ==
numeric_limits<double>::min(), then ld == hi + low > 1.0. If you don't look
any further, then you have to conclude epsilon == low.
However, Geoffrey Keating lists under "Classification" all valid bit patterns
for a long double. He explicitly states:
Many possible long double bit patterns are not valid long doubles.
These do not represent any value.
ld = hi + low as above is not among the bit patterns he lists as valid. If you
apply the definition of epsilon to the "normal" long doubles only, then you get
a value like the one Paul Bristow computed for NTL's quad_float.
Christoph
 http://www.informatik.tudarmstadt.de/TI/Mitarbeiter/cludwig.html LiDIA: http://www.informatik.tudarmstadt.de/TI/LiDIA/Welcome.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk