Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1ee3e817
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看板
提交
1ee3e817
编写于
2月 08, 2011
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
4421494: infinite loop while parsing double literal
Reviewed-by: darcy, alanb Contributed-by: dmitry.nadezhin@oracle.com
上级
615ec5db
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
3 deletion
+40
-3
src/share/classes/sun/misc/FloatingDecimal.java
src/share/classes/sun/misc/FloatingDecimal.java
+1
-1
test/java/lang/Double/ParseDouble.java
test/java/lang/Double/ParseDouble.java
+39
-2
未找到文件。
src/share/classes/sun/misc/FloatingDecimal.java
浏览文件 @
1ee3e817
...
@@ -1547,7 +1547,7 @@ public class FloatingDecimal{
...
@@ -1547,7 +1547,7 @@ public class FloatingDecimal{
if
(
(
cmpResult
=
bigB
.
cmp
(
bigD
)
)
>
0
){
if
(
(
cmpResult
=
bigB
.
cmp
(
bigD
)
)
>
0
){
overvalue
=
true
;
// our candidate is too big.
overvalue
=
true
;
// our candidate is too big.
diff
=
bigB
.
sub
(
bigD
);
diff
=
bigB
.
sub
(
bigD
);
if
(
(
bigIntNBits
==
1
)
&&
(
bigIntExp
>
-
expBias
)
){
if
(
(
bigIntNBits
==
1
)
&&
(
bigIntExp
>
-
expBias
+
1
)
){
// candidate is a normalized exact power of 2 and
// candidate is a normalized exact power of 2 and
// is too big. We will be subtracting.
// is too big. We will be subtracting.
// For our purposes, ulp is the ulp of the
// For our purposes, ulp is the ulp of the
...
...
test/java/lang/Double/ParseDouble.java
浏览文件 @
1ee3e817
...
@@ -23,11 +23,12 @@
...
@@ -23,11 +23,12 @@
/*
/*
* @test
* @test
* @bug 4160406 4705734 4707389 4826774 4895911
* @bug 4160406 4705734 4707389 4826774 4895911
4421494
* @summary Test for Double.parseDouble method and acceptance regex
* @summary Test for Double.parseDouble method and acceptance regex
*/
*/
import
java.util.regex.*
;
import
java.util.regex.*
;
import
java.math.BigDecimal
;
public
class
ParseDouble
{
public
class
ParseDouble
{
...
@@ -416,7 +417,15 @@ public class ParseDouble {
...
@@ -416,7 +417,15 @@ public class ParseDouble {
"0x00100p1"
,
"0x00100p1"
,
"0x00.100p1"
,
"0x00.100p1"
,
"0x001.100p1"
"0x001.100p1"
,
// Limits
"1.7976931348623157E308"
,
// Double.MAX_VALUE
"4.9e-324"
,
// Double.MIN_VALUE
"2.2250738585072014e-308"
,
// Double.MIN_NORMAL
"2.2250738585072012e-308"
,
// near Double.MIN_NORMAL
};
};
static
String
paddedBadStrings
[];
static
String
paddedBadStrings
[];
...
@@ -546,6 +555,32 @@ public class ParseDouble {
...
@@ -546,6 +555,32 @@ public class ParseDouble {
}
}
/**
* For each subnormal power of two, test at boundaries of
* region that should convert to that value.
*/
private
static
void
testSubnormalPowers
()
{
BigDecimal
TWO
=
BigDecimal
.
valueOf
(
2
);
// An ulp is the same for all subnormal values
BigDecimal
ulp_BD
=
new
BigDecimal
(
Double
.
MIN_VALUE
);
// Test subnormal powers of two
for
(
int
i
=
-
1074
;
i
<=
-
1022
;
i
++)
{
double
d
=
Math
.
scalb
(
1.0
,
i
);
/*
* The region [d - ulp/2, d + ulp/2] should round to d.
*/
BigDecimal
d_BD
=
new
BigDecimal
(
d
);
BigDecimal
lowerBound
=
d_BD
.
subtract
(
ulp_BD
.
divide
(
TWO
));
BigDecimal
upperBound
=
d_BD
.
add
(
ulp_BD
.
divide
(
TWO
));
double
convertedLowerBound
=
Double
.
parseDouble
(
lowerBound
.
toString
());
double
convertedUpperBound
=
Double
.
parseDouble
(
upperBound
.
toString
());
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
rudimentaryTest
();
rudimentaryTest
();
...
@@ -558,5 +593,7 @@ public class ParseDouble {
...
@@ -558,5 +593,7 @@ public class ParseDouble {
testRegex
(
paddedGoodStrings
,
false
);
testRegex
(
paddedGoodStrings
,
false
);
testRegex
(
badStrings
,
true
);
testRegex
(
badStrings
,
true
);
testRegex
(
paddedBadStrings
,
true
);
testRegex
(
paddedBadStrings
,
true
);
testSubnormalPowers
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录