Mark P wrote:

I have a float value which should be initialized to the minimum allowed

value (analogous to -infinity).

What about actually using -infinity?

float init = numeric_limits<float>::has_infinity

? -numeric_limits<float>::infinity()

: -numeric_limits<float>::max();

I discovered today (thank you, unit

tests!) that numeric_limits<float>::min() returns a very small number

greater than 0, rather than the extremely negative number which I want.

Is it safe to use -numeric_limits<float>::max() for this purpose

In general? I suppose no. In practice, if your "float" represents

an IEEE754/854 number (a very common floating point standard), then you

should be safe, since a sign bit stored separately (no two's

complement).

Greg Buchholz