浮点数精度问题
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 20/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- java
- Domain
- documentation
Research direction
The issue contains Java examples explaining floating-point precision, but it names no file, test, or entry point and does not request a specific change. First identify where this explanation belongs in the repository; completion is undefined until the desired documentation update and its location are specified.
Written by the indexing model from the issue text.
Description
精度问题出现的本质原因是浮点数无法精确的表示大多数十进制小数,以下面的计算为例:
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都是可以精确表示的,所以最后的结果便是对的。
- Dominant language
- Java
- Stars
- 2k
- Forks
- 717
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from seaswalker/jdk-sourcecode-analysis
-
一种从值转为枚举的方法 Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
-
JMM和Linux内存屏障定义 Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
令人迷惑的volatile例子(三) Open
Difficulty 5/5 Over a week Newbie friendliness 18/100
-
令人迷惑的volatile例子(二) Open
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in seaswalker/jdk-sourcecode-analysis
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
objectionary/hone-maven-plugin#1061 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
spring-projects/spring-modulith#1895 ·