-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Misc] optimize BigDecimal.divide #849
Conversation
Class<BigDecimal> clazz = BigDecimal.class; | ||
Field optField = clazz.getDeclaredField("opt"); | ||
optField.setAccessible(true); | ||
SecureRandom random = new SecureRandom(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要加一些边界条件检查,不能全依赖随机测试
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要加一些边界条件检查,不能全依赖随机测试
好的, 增加了下列特殊情况
0.00000000000000D,
123456789.123456789, -123456789.123456789,
1e10, 1e-010, -1e10, -1e-010,
Double.MAX_VALUE, Double.MIN_VALUE,
-Double.MAX_VALUE, -Double.MIN_VALUE
@@ -368,6 +368,18 @@ protected StringBuilderHelper initialValue() { | |||
*/ | |||
private static final BigDecimal ONE_HALF = valueOf(5L, 1); | |||
|
|||
private static boolean opt; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否应该在opt声明的时候加上默认值,下面的try-catch没有final语句,如果有一些特殊异常情况可能导致opt没赋上值
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已完成,默认设置false
7a96e2c
to
5f9464c
Compare
Summary: Use binary search in zero stripping of BigDecimal.divide Testing: jtreg and ci Reviewers: zhuoren.wz, JoshuaZhuwj Issue: #848
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Summary: Use binary search in zero stripping of BigDecimal.divide
Testing: jtreg
Reviewers:
Issue: #848