Java: double vs float

后端 未结 6 1197
一整个雨季
一整个雨季 2020-12-09 16:37

In another Bruce Eckel exercise, the code I\'ve written takes a method and changes value in another class. Here is my code:

class Big {
  float b;
}

public         


        
6条回答
  •  抹茶落季
    2020-12-09 17:01

    No, floats can be automatically upcast to doubles, but doubles can never be floats without explicit casting because doubles have the larger range.

    float range is 1.40129846432481707e-45 to 3.40282346638528860e+38

    double range is 4.94065645841246544e-324d to 1.79769313486231570e+308d

提交回复
热议问题