soeren@all-about-shift.com wrote:[color=blue]
> cout << numeric_limits<double>::min() << endl;
>
> returns "2.22507e-308". So I would expect that every number closer to
> zero (but still negative) would be treated as zero?[/color]
Note that this is (a printed approximation) to the smallest /normal/
number.
The IEEE 754 double precision format allows for smaller magnitudes than
that, in the form of denormal numbers.
Note that the numeric_limits system has a denorm_min() function.
[color=blue]
> double foobar = -2.345e-315;[/color]
So here, you are in the territory of denormals. Denormals have the
smallest possible exponent, but the mantissa is interpreted as not
having the implicit leading 1.
You can think of zero as being a special case of the the denormals.
Or, conversely, as denormals being extensions to zero where the
mantissa bits are used to encode tiny values near to zero.
The smallest positive denormal (or, in alternate terminology,
subnormal) is approximately 4.94E-324. As you can see, this is quite a
bit smaller still than the denormal you are representing in your
program.