Skip to content

建议:修改RoundingMode的样例中注释采用的数据 #2663

New issue

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

1312255201
Copy link
Contributor

@1312255201 1312255201 commented Apr 15, 2025

作者您好,在阅读《BigDecimal 详解》一文当中,在介绍使用 RoundingMode的几种模式中,文中的样例注释当中使用了2.5 -2.5 1.6 -1.6这四个数作为的样例,但是对于最后一个四舍五入的方法没有区分度,均为大于5的数进位。所以我提议将2.5改为2.4,-2.5改为-2.4来进行区分,做了如下修改,并且使用java程序已验证正确性,希望可以合并

测试数据 2.4, -2.4, 1.6, -1.6
Rounding模式: UP
2.4 -> 3
-2.4 -> -3
1.6 -> 2
-1.6 -> -2
Rounding模式: DOWN
2.4 -> 2
-2.4 -> -2
1.6 -> 1
-1.6 -> -1
Rounding模式: CEILING
2.4 -> 3
-2.4 -> -2
1.6 -> 2
-1.6 -> -1
Rounding模式: FLOOR
2.4 -> 2
-2.4 -> -3
1.6 -> 1
-1.6 -> -2
Rounding模式: HALF_UP
2.4 -> 2
-2.4 -> -2
1.6 -> 2
-1.6 -> -2

@Snailclimb
Copy link
Owner

作者您好,在阅读《BigDecimal 详解》一文当中,在介绍使用 RoundingMode的几种模式中,文中的样例注释当中使用了2.5 -2.5 1.6 -1.6这四个数作为的样例,但是对于最后一个四舍五入的方法没有区分度,均为大于5的数进位。所以我提议将2.5改为2.4,-2.5改为-2.4来进行区分,做了如下修改,并且使用java程序已验证正确性,希望可以合并

测试数据 2.4, -2.4, 1.6, -1.6
Rounding模式: UP
2.4 -> 3
-2.4 -> -3
1.6 -> 2
-1.6 -> -2
Rounding模式: DOWN
2.4 -> 2
-2.4 -> -2
1.6 -> 1
-1.6 -> -1
Rounding模式: CEILING
2.4 -> 3
-2.4 -> -2
1.6 -> 2
-1.6 -> -1
Rounding模式: FLOOR
2.4 -> 2
-2.4 -> -3
1.6 -> 1
-1.6 -> -2
Rounding模式: HALF_UP
2.4 -> 2
-2.4 -> -2
1.6 -> 2
-1.6 -> -2

感谢完善👍

@Snailclimb Snailclimb merged commit 1fc64fc into Snailclimb:main Apr 24, 2025
@Snailclimb Snailclimb added the enhancement New feature or request or suggestion label Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request or suggestion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants