Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ffa2ff39
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ffa2ff39
编写于
9月 05, 2011
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7086710: java/util/Formatter/Basic.java failing after 7082971
Reviewed-by: alanb
上级
0c6092d8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
15 deletion
+29
-15
src/share/classes/java/math/BigDecimal.java
src/share/classes/java/math/BigDecimal.java
+29
-15
未找到文件。
src/share/classes/java/math/BigDecimal.java
浏览文件 @
ffa2ff39
...
@@ -904,12 +904,13 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
...
@@ -904,12 +904,13 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
throw
new
NumberFormatException
(
"Infinite or NaN"
);
throw
new
NumberFormatException
(
"Infinite or NaN"
);
// Translate the double into sign, exponent and significand, according
// Translate the double into sign, exponent and significand, according
// to the formulae in JLS, Section 20.10.22.
// to the formulae in JLS, Section 20.10.22.
int
sign
=
(
val
>=
0.0
?
1
:
-
1
);
// Preserving sign of zero doesn't matter
int
exponent
=
Math
.
getExponent
(
val
);
long
valBits
=
Double
.
doubleToLongBits
(
val
);
long
valBits
=
Double
.
doubleToLongBits
(
val
);
long
significand
=
(
exponent
==
(
Double
.
MIN_EXPONENT
-
1
)
int
sign
=
((
valBits
>>
63
)
==
0
?
1
:
-
1
);
?
(
valBits
&
((
1L
<<
52
)
-
1
))
<<
1
int
exponent
=
(
int
)
((
valBits
>>
52
)
&
0x7ff
L
);
:
(
valBits
&
((
1L
<<
52
)
-
1
))
|
(
1L
<<
52
));
long
significand
=
(
exponent
==
0
?
(
valBits
&
((
1L
<<
52
)
-
1
))
<<
1
:
(
valBits
&
((
1L
<<
52
)
-
1
))
|
(
1L
<<
52
));
exponent
-=
1075
;
// At this point, val == sign * significand * 2**exponent.
// At this point, val == sign * significand * 2**exponent.
/*
/*
...
@@ -933,9 +934,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
...
@@ -933,9 +934,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
BigInteger
intVal
;
BigInteger
intVal
;
long
compactVal
=
sign
*
significand
;
long
compactVal
=
sign
*
significand
;
if
(
exponent
==
0
)
{
if
(
exponent
==
0
)
{
// If the exponent is zero, the significant fits in a long
intVal
=
(
compactVal
==
INFLATED
)
?
INFLATED_BIGINT
:
null
;
assert
compactVal
!=
INFLATED
;
intVal
=
null
;
}
else
{
}
else
{
if
(
exponent
<
0
)
{
if
(
exponent
<
0
)
{
intVal
=
BigInteger
.
valueOf
(
5
).
pow
(-
exponent
).
multiply
(
compactVal
);
intVal
=
BigInteger
.
valueOf
(
5
).
pow
(-
exponent
).
multiply
(
compactVal
);
...
@@ -4162,15 +4161,30 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
...
@@ -4162,15 +4161,30 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
return
qsign
<
0
;
return
qsign
<
0
;
default
:
// Some kind of half-way rounding
default
:
// Some kind of half-way rounding
if
(
roundingMode
==
ROUND_HALF_DOWN
||
assert
roundingMode
>=
ROUND_HALF_UP
&&
cmpFracHalf
<
0
)
// We're closer to higher digit
roundingMode
<=
ROUND_HALF_EVEN:
"Unexpected rounding mode"
+
RoundingMode
.
valueOf
(
roundingMode
);
if
(
cmpFracHalf
<
0
)
// We're closer to higher digit
return
false
;
return
false
;
else
if
(
roundingMode
==
ROUND_HALF_UP
||
else
if
(
cmpFracHalf
>
0
)
// We're closer to lower digit
cmpFracHalf
>
0
)
// We're closer to lower digit
return
true
;
return
true
;
else
else
{
// half-way
// roundingMode == ROUND_HALF_EVEN, true iff quotient is odd
assert
cmpFracHalf
==
0
;
return
oddQuot
;
switch
(
roundingMode
)
{
case
ROUND_HALF_DOWN:
return
false
;
case
ROUND_HALF_UP:
return
true
;
case
ROUND_HALF_EVEN:
return
oddQuot
;
default
:
throw
new
AssertionError
(
"Unexpected rounding mode"
+
roundingMode
);
}
}
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录