为什么返回两个不同的答案?

问题描述 投票:0回答:1

当我运行此代码时,这些是我得到的答案:2678.9854&2677.311

这是一个四舍五入的问题,还是这两个单独的问题?

private float x = 2745.96f;
private float percent = 0.025f;

public String calculate()
{
    float divide = x / (1 + percent);
    float subtract = x - (x * percent);

    return String.valueOf(divide) + " " + String.valueOf(subtract);
}
java math theory
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.