Is there a standard and/or portable way to represent the smallest negative value (e.g. to use negative infinity) in a C(++) program?
DBL_MIN in float.h is the smalle
Are you looking for actual infinity or the minimal finite value? If the former, use
-numeric_limits::infinity()
which only works if
numeric_limits::has_infinity
Otherwise, you should use
numeric_limits::lowest()
which was introduces in C++11.
If lowest() is not available, you can fall back to
-numeric_limits::max()
which may differ from lowest() in principle, but normally doesn't in practice.