Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 2ed417fa3c409aaeb00bcf04c36dd8d21ece488c..169307fb8e077c8cb4513f6f9fdaa489ac2dc26d 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -1005,8 +1005,11 @@ bool Object::SameValue(Object* other) { |
| if (IsNumber() && other->IsNumber()) { |
| double this_value = Number(); |
| double other_value = other->Number(); |
| - return (this_value == other_value) || |
| - (std::isnan(this_value) && std::isnan(other_value)); |
| + bool equal = this_value == other_value; |
| + // SameValue(NaN, NaN) is true. |
| + if (!equal) return std::isnan(this_value) && std::isnan(other_value); |
| + // SameValue(0.0, -0.0) is false. |
| + return (this_value != 0) || ((1 / this_value) == (1 / other_value)); |
|
yusukesuzuki
2013/09/24 12:58:26
According to the comment of Object::SameValue in o
|
| } |
| if (IsString() && other->IsString()) { |
| return String::cast(this)->Equals(String::cast(other)); |