Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
fe7ceb20
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看板
提交
fe7ceb20
编写于
12月 01, 2010
作者:
D
darcy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7002594: Math.max and Math.min should use floatToRawIntBits() to check for -0.0
Reviewed-by: mduigou, lancea, alanb
上级
89389743
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
166 addition
and
163 deletion
+166
-163
src/share/classes/java/lang/Double.java
src/share/classes/java/lang/Double.java
+3
-2
src/share/classes/java/lang/Float.java
src/share/classes/java/lang/Float.java
+4
-3
src/share/classes/java/lang/StrictMath.java
src/share/classes/java/lang/StrictMath.java
+28
-15
src/share/classes/sun/misc/FpUtils.java
src/share/classes/sun/misc/FpUtils.java
+131
-143
未找到文件。
src/share/classes/java/lang/Double.java
浏览文件 @
fe7ceb20
/*
* Copyright (c) 1994, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 20
10
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -973,7 +973,8 @@ public final class Double extends Number implements Comparable<Double> {
if
(
d1
>
d2
)
return
1
;
// Neither val is NaN, thisVal is larger
long
thisBits
=
Double
.
doubleToLongBits
(
d1
);
// Cannot use doubleToRawLongBits because of possibility of NaNs.
long
thisBits
=
Double
.
doubleToLongBits
(
d1
);
long
anotherBits
=
Double
.
doubleToLongBits
(
d2
);
return
(
thisBits
==
anotherBits
?
0
:
// Values are equal
...
...
src/share/classes/java/lang/Float.java
浏览文件 @
fe7ceb20
/*
* Copyright (c) 1994, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 20
10
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -872,12 +872,13 @@ public final class Float extends Number implements Comparable<Float> {
* @since 1.4
*/
public
static
int
compare
(
float
f1
,
float
f2
)
{
if
(
f1
<
f2
)
if
(
f1
<
f2
)
return
-
1
;
// Neither val is NaN, thisVal is smaller
if
(
f1
>
f2
)
return
1
;
// Neither val is NaN, thisVal is larger
int
thisBits
=
Float
.
floatToIntBits
(
f1
);
// Cannot use floatToRawIntBits because of possibility of NaNs.
int
thisBits
=
Float
.
floatToIntBits
(
f1
);
int
anotherBits
=
Float
.
floatToIntBits
(
f2
);
return
(
thisBits
==
anotherBits
?
0
:
// Values are equal
...
...
src/share/classes/java/lang/StrictMath.java
浏览文件 @
fe7ceb20
/*
* Copyright (c) 1999, 20
06
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
10
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
...
...
@@ -801,8 +801,9 @@ public final class StrictMath {
return
(
a
>=
b
)
?
a
:
b
;
}
private
static
long
negativeZeroFloatBits
=
Float
.
floatToIntBits
(-
0.0f
);
private
static
long
negativeZeroDoubleBits
=
Double
.
doubleToLongBits
(-
0.0d
);
// Use raw bit-wise conversions on guaranteed non-NaN arguments.
private
static
long
negativeZeroFloatBits
=
Float
.
floatToRawIntBits
(-
0.0f
);
private
static
long
negativeZeroDoubleBits
=
Double
.
doubleToRawLongBits
(-
0.0d
);
/**
* Returns the greater of two {@code float} values. That is,
...
...
@@ -819,9 +820,12 @@ public final class StrictMath {
* @return the larger of {@code a} and {@code b}.
*/
public
static
float
max
(
float
a
,
float
b
)
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0f
)
&&
(
b
==
0.0f
)
&&
(
Float
.
floatToIntBits
(
a
)
==
negativeZeroFloatBits
))
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0f
)
&&
(
b
==
0.0f
)
&&
(
Float
.
floatToRawIntBits
(
a
)
==
negativeZeroFloatBits
))
{
// Raw conversion ok since NaN can't map to -0.0.
return
b
;
}
return
(
a
>=
b
)
?
a
:
b
;
...
...
@@ -842,9 +846,12 @@ public final class StrictMath {
* @return the larger of {@code a} and {@code b}.
*/
public
static
double
max
(
double
a
,
double
b
)
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0d
)
&&
(
b
==
0.0d
)
&&
(
Double
.
doubleToLongBits
(
a
)
==
negativeZeroDoubleBits
))
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0d
)
&&
(
b
==
0.0d
)
&&
(
Double
.
doubleToRawLongBits
(
a
)
==
negativeZeroDoubleBits
))
{
// Raw conversion ok since NaN can't map to -0.0.
return
b
;
}
return
(
a
>=
b
)
?
a
:
b
;
...
...
@@ -893,9 +900,12 @@ public final class StrictMath {
* @return the smaller of {@code a} and {@code b.}
*/
public
static
float
min
(
float
a
,
float
b
)
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0f
)
&&
(
b
==
0.0f
)
&&
(
Float
.
floatToIntBits
(
b
)
==
negativeZeroFloatBits
))
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0f
)
&&
(
b
==
0.0f
)
&&
(
Float
.
floatToRawIntBits
(
b
)
==
negativeZeroFloatBits
))
{
// Raw conversion ok since NaN can't map to -0.0.
return
b
;
}
return
(
a
<=
b
)
?
a
:
b
;
...
...
@@ -916,9 +926,12 @@ public final class StrictMath {
* @return the smaller of {@code a} and {@code b}.
*/
public
static
double
min
(
double
a
,
double
b
)
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0d
)
&&
(
b
==
0.0d
)
&&
(
Double
.
doubleToLongBits
(
b
)
==
negativeZeroDoubleBits
))
{
if
(
a
!=
a
)
return
a
;
// a is NaN
if
((
a
==
0.0d
)
&&
(
b
==
0.0d
)
&&
(
Double
.
doubleToRawLongBits
(
b
)
==
negativeZeroDoubleBits
))
{
// Raw conversion ok since NaN can't map to -0.0.
return
b
;
}
return
(
a
<=
b
)
?
a
:
b
;
...
...
src/share/classes/sun/misc/FpUtils.java
浏览文件 @
fe7ceb20
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录