On Mon, Jul 22, 2013 at 11:02:28PM +0200, Joseph Rushton Wakeling wrote: > Always amusing to run into those little quirks of parts of the > language you've never worked with before ... > > I just realized that while e.g. int.min gives a negative value, the > floating point equivalent, e.g. double.min, gives a very small > positive value -- I guess the smallest possible positive value. > > I guess this is intentional, so I thought I'd ask why -- it's a > little unintuitive after the integral type behaviour. > > Also, how can I get the truly least value of a floating point > number? I guess with e.g. -double.max ... ?
I believe double.min has been deprecated. In any case, it is a misnomer. Basically, it's supposed to give the smallest representable "normal" float, that is, it's the non-zero positive number with the smallest possible exponent and smallest possible mantissa. The new name for this IIRC is .min_normal. There are some floats that can go even smaller than this, but they are "denormal" and may incur a large runtime overhead (they are intended to prevent underflow / minimize loss of precision in certain computations involving very small quantities, and aren't supposed to be used in normal calculations). tl;dr: don't use double.min, use -double.max. :) T -- Век живи - век учись. А дураком помрёшь.