Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Side by Side Diff: runtime/lib/double.dart

Issue 1160453003: Fix 23563: double unary- operator unstable for NANs (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: g Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _Double extends _Num implements double { 5 class _Double extends _Num implements double {
6 factory _Double.fromInteger(int value) 6 factory _Double.fromInteger(int value)
7 native "Double_doubleFromInteger"; 7 native "Double_doubleFromInteger";
8 8
9 Type get runtimeType => double; 9 Type get runtimeType => double;
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 double remainder(num other) { 45 double remainder(num other) {
46 return _remainder(other.toDouble()); 46 return _remainder(other.toDouble());
47 } 47 }
48 double _remainder(double other) native "Double_remainder"; 48 double _remainder(double other) native "Double_remainder";
49 double operator -() { 49 double operator -() {
50 if (this == 0.0) { 50 if (this == 0.0) {
51 // -0.0 is canonicalized by the VM's parser, therefore no cycles. 51 // -0.0 is canonicalized by the VM's parser, therefore no cycles.
52 return isNegative ? 0.0 : -0.0; 52 return isNegative ? 0.0 : -0.0;
53 } 53 }
54 if (this.isNaN) {
55 return this._flipNANsign;
56 }
54 return 0.0 - this; 57 return 0.0 - this;
55 } 58 }
59 double get _flipNANsign native "Double_flipNANsign";
60
56 bool operator ==(other) { 61 bool operator ==(other) {
57 if (!(other is num)) return false; 62 if (!(other is num)) return false;
58 return _equal(other.toDouble()); 63 return _equal(other.toDouble());
59 } 64 }
60 bool _equal(double other)native "Double_equal"; 65 bool _equal(double other)native "Double_equal";
61 bool _equalToInteger(int other) native "Double_equalToInteger"; 66 bool _equalToInteger(int other) native "Double_equalToInteger";
62 bool operator <(num other) { 67 bool operator <(num other) {
63 return other > this; 68 return other > this;
64 } 69 }
65 bool operator >(num other) { 70 bool operator >(num other) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return EQUAL; 269 return EQUAL;
265 } 270 }
266 } else if (isNaN) { 271 } else if (isNaN) {
267 return other.isNaN ? EQUAL : GREATER; 272 return other.isNaN ? EQUAL : GREATER;
268 } else { 273 } else {
269 // Other is NaN. 274 // Other is NaN.
270 return LESS; 275 return LESS;
271 } 276 }
272 } 277 }
273 } 278 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698