minimum double value in C/C++

后端 未结 10 1400
天命终不由人
天命终不由人 2020-12-04 08:41

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

10条回答
  •  醉梦人生
    2020-12-04 09:27

    Try this:

    -1 * numeric_limits::max()
    

    Reference: numeric_limits

    This class is specialized for each of the fundamental types, with its members returning or set to the different values that define the properties that type has in the specific platform in which it compiles.

提交回复
热议问题