Why is there a “d” in the definition of Double.NaN = 0.0d / 0.0?

后端 未结 3 949
[愿得一人]
[愿得一人] 2020-12-11 00:01

I just came across the definition of NaN in Double.class. It says:

 /**
   * A constant holding a Not-a-Number (NaN) value of type
         


        
3条回答
  •  醉话见心
    2020-12-11 00:28

    There is no difference between 0.0 and 0.0d as Java takes doubles by default to represent floating point numbers.

    Still, the code is more readable as in many languages, float is the default as well as it was in Oak later evolved to become Java so it looks like historical issue.

    --Link found by Andy Turner.

提交回复
热议问题