Maximum value for Float in Java?

前端 未结 5 622
一整个雨季
一整个雨季 2021-02-05 02:54

The following question indicates that the minimum value of a Double is -Double.MAX_VALUE. Is this also true for Float (i.e., -Float.MAX_VALUE)?

5条回答
  •  独厮守ぢ
    2021-02-05 03:27

    EDIT: My original answer appears to be badly incorrect. Thank you @aioobe for pointing this out.

    Instead, using the magic of java code to answer the title question:

    System.out.printf( "Float.MAX_VALUE: %,f\n", Float.MAX_VALUE );
    

    Float.MAX_VALUE: 340,282,346,638,528,860,000,000,000,000,000,000,000.000000

    System.out.printf("in scientific notation: %.18g\n", Float.MAX_VALUE );
    

    in scientific notation: 3.40282346638528860e+38

    System.out.printf(
                "in hexadecimal floating-point number with a significand and "
                + "an exponent: %a", Float.MAX_VALUE );
    

    in hexadecimal floating-point number with a significand and an exponent: 0x1.fffffep127

提交回复
热议问题