Why does numeric_limits::min return a negative value for int but positive values for float/double?

前端 未结 2 485
南方客
南方客 2020-12-29 02:32

Why does numeric_limits::min return a negative value for int, but positive values for e.g. float and double?

#include
#inclu         


        
2条回答
  •  忘掉有多难
    2020-12-29 03:11

    It's unfortunate, but behind similar names completely different meaning lies. It was kinda carried over from C, where DBL_MIN and INT_MIN has the very same "problem".

    As not much can be done, just remember what means what.

提交回复
热议问题