在Java中,“ double”和“ float”之间的用法有什么区别

例如,

double firstNumber, secondNumber, thirdNumber, answer;

firstNumber = 75.5;
secondNumber = 25.9;
thirdNumber = 25.7;
answer = (firstNumber + secondNumber) * thirdNumber;

System.out.println("Calculation_Total = " + answer );

给出正确的结果,而使用“ float”则给出错误消息。

评论