Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7ccadbc7
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看板
提交
7ccadbc7
编写于
4月 17, 2011
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7021568: Double.parseDouble() returns architecture dependent results
Reviewed-by: alanb
上级
8e59b2ad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
4 deletion
+30
-4
src/share/classes/sun/misc/FloatingDecimal.java
src/share/classes/sun/misc/FloatingDecimal.java
+1
-1
src/share/classes/sun/misc/FormattedFloatingDecimal.java
src/share/classes/sun/misc/FormattedFloatingDecimal.java
+2
-2
test/java/lang/Double/ParseDouble.java
test/java/lang/Double/ParseDouble.java
+27
-1
未找到文件。
src/share/classes/sun/misc/FloatingDecimal.java
浏览文件 @
7ccadbc7
...
@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts;
...
@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts;
import
sun.misc.FloatConsts
;
import
sun.misc.FloatConsts
;
import
java.util.regex.*
;
import
java.util.regex.*
;
public
class
FloatingDecimal
{
public
strictfp
class
FloatingDecimal
{
boolean
isExceptional
;
boolean
isExceptional
;
boolean
isNegative
;
boolean
isNegative
;
int
decExponent
;
int
decExponent
;
...
...
src/share/classes/sun/misc/FormattedFloatingDecimal.java
浏览文件 @
7ccadbc7
/*
/*
* Copyright (c) 2003, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 20
11
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts;
...
@@ -30,7 +30,7 @@ import sun.misc.DoubleConsts;
import
sun.misc.FloatConsts
;
import
sun.misc.FloatConsts
;
import
java.util.regex.*
;
import
java.util.regex.*
;
public
class
FormattedFloatingDecimal
{
public
strictfp
class
FormattedFloatingDecimal
{
boolean
isExceptional
;
boolean
isExceptional
;
boolean
isNegative
;
boolean
isNegative
;
int
decExponent
;
// value set at construction, then immutable
int
decExponent
;
// value set at construction, then immutable
...
...
test/java/lang/Double/ParseDouble.java
浏览文件 @
7ccadbc7
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/*
/*
* @test
* @test
* @bug 4160406 4705734 4707389 4826774 4895911 4421494
* @bug 4160406 4705734 4707389 4826774 4895911 4421494
7021568
* @summary Test for Double.parseDouble method and acceptance regex
* @summary Test for Double.parseDouble method and acceptance regex
*/
*/
...
@@ -581,6 +581,31 @@ public class ParseDouble {
...
@@ -581,6 +581,31 @@ public class ParseDouble {
}
}
}
}
private
static
void
testStrictness
()
{
final
double
expected
=
0x0
.
000000
8000001
p
-
1022
;
boolean
failed
=
false
;
double
conversion
=
0.0
;
double
sum
=
0.0
;
// Prevent conversion from being optimized away
//2^-1047 + 2^-1075
String
decimal
=
"6.631236871469758276785396630275967243399099947355303144249971758736286630139265439618068200788048744105960420552601852889715006376325666595539603330361800519107591783233358492337208057849499360899425128640718856616503093444922854759159988160304439909868291973931426625698663157749836252274523485312442358651207051292453083278116143932569727918709786004497872322193856150225415211997283078496319412124640111777216148110752815101775295719811974338451936095907419622417538473679495148632480391435931767981122396703443803335529756003353209830071832230689201383015598792184172909927924176339315507402234836120730914783168400715462440053817592702766213559042115986763819482654128770595766806872783349146967171293949598850675682115696218943412532098591327667236328125E-316"
;
for
(
int
i
=
0
;
i
<=
12_000
;
i
++)
{
conversion
=
Double
.
parseDouble
(
decimal
);
sum
+=
conversion
;
if
(
conversion
!=
expected
)
{
failed
=
true
;
System
.
out
.
printf
(
"Iteration %d converts as %a%n"
,
i
,
conversion
);
}
}
System
.
out
.
println
(
"Sum = "
+
sum
);
if
(
failed
)
throw
new
RuntimeException
(
"Inconsistent conversion"
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
rudimentaryTest
();
rudimentaryTest
();
...
@@ -595,5 +620,6 @@ public class ParseDouble {
...
@@ -595,5 +620,6 @@ public class ParseDouble {
testRegex
(
paddedBadStrings
,
true
);
testRegex
(
paddedBadStrings
,
true
);
testSubnormalPowers
();
testSubnormalPowers
();
testStrictness
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录