在 Java 中,应用数学函数时精度下降
In Java, losing accuracy while applying math functions
我在使用 java 数学函数时得到错误的输出。
预期产出 = 4.32
当前输出= 4.30287105016515
double startHeight= 60.00;
double initaldistance=1000.00;
double speed=120;
startDistance=(initaldistance-1.688*speed);
startAngle = Math.toDegrees(Math.atan(startHeight/startDistance));
System.out.println(startAngle);
您预期的输出不正确。题中代码所表达的算术确实有接近4.30287的结果。
我在使用 java 数学函数时得到错误的输出。 预期产出 = 4.32 当前输出= 4.30287105016515
double startHeight= 60.00;
double initaldistance=1000.00;
double speed=120;
startDistance=(initaldistance-1.688*speed);
startAngle = Math.toDegrees(Math.atan(startHeight/startDistance));
System.out.println(startAngle);
您预期的输出不正确。题中代码所表达的算术确实有接近4.30287的结果。