Why is FLT_MIN equal to zero?

前端 未结 4 1269
情歌与酒
情歌与酒 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:40

    The '%f' format prints 6 decimal places in fixed format. Since FLT_MIN is a lot smaller, it looks like zero in fixed point. If you use '%e' or '%g' format, you'd get a better formatted answer. Similarly with the FLT_MAX.

    #include 
    #include 
    int main(void)
    {
        printf("MIN = %f, MAX = %f\n", FLT_MIN, FLT_MAX);
        printf("MIN = %e, MAX = %e\n", FLT_MIN, FLT_MAX);
        return(0);
    }
    
    
    MIN = 0.000000, MAX = 340282346638528859811704183484516925440.000000
    MIN = 1.175494e-38, MAX = 3.402823e+38
    

提交回复
热议问题