Why is FLT_MIN equal to zero?

前端 未结 4 1267
情歌与酒
情歌与酒 2020-12-01 07:47

limits.h specifies limits for non-floating point math types, e.g. INT_MIN and INT_MAX. These values are the most negative and most pos

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-01 08:20

    It's not actually zero, but it might look like zero if you inspect it using printf or NSLog by using %f.
    According to float.h (at least in Mac OS X 10.6.2), FLT_MIN is described as:

    /* Minimum normalized positive floating-point number, b**(emin - 1).  */
    

    Note the positive in that sentence: FLT_MIN refers to the minimum (normalized) number greater than zero. (There are much smaller non-normalized numbers).

    If you want the minimum floating point number (including negative numbers), use -FLT_MAX.

提交回复
热议问题