We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
精度问题出现的本质原因是浮点数无法精确的表示大多数十进制小数,以下面的计算为例:
System.out.println(81.6 * 10); System.out.println(81.6 * 100);
其输出结果是:
816.0 8159.999999999999
数字81.6在写出来之后就不是精确表示了,随后的计算所以也随之不准确。下面的除法是准确的:
System.out.println(816 / 100D);
因为对于整数,816和100都是可以精确表示的,所以最后的结果便是对的。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
精度问题出现的本质原因是浮点数无法精确的表示大多数十进制小数,以下面的计算为例:
其输出结果是:
数字81.6在写出来之后就不是精确表示了,随后的计算所以也随之不准确。下面的除法是准确的:
因为对于整数,816和100都是可以精确表示的,所以最后的结果便是对的。
The text was updated successfully, but these errors were encountered: