Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 29 matching lines...) Expand all Loading... | |
| 40 double operator %(num other) { | 40 double operator %(num other) { |
| 41 return _modulo(other.toDouble()); | 41 return _modulo(other.toDouble()); |
| 42 } | 42 } |
| 43 double _modulo(double other) native "Double_modulo"; | 43 double _modulo(double other) native "Double_modulo"; |
| 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 // Handles properly 0.0, NAN, and other doubles. |
| 51 // -0.0 is canonicalized by the VM's parser, therefore no cycles. | 51 return this._flipSignBit; |
|
srdjan
2015/06/02 22:32:10
Calling out to native should not be a performance
| |
| 52 return isNegative ? 0.0 : -0.0; | |
| 53 } | |
| 54 return 0.0 - this; | |
| 55 } | 52 } |
| 53 double get _flipSignBit native "Double_flipSignBit"; | |
| 54 | |
| 56 bool operator ==(other) { | 55 bool operator ==(other) { |
| 57 if (!(other is num)) return false; | 56 if (!(other is num)) return false; |
| 58 return _equal(other.toDouble()); | 57 return _equal(other.toDouble()); |
| 59 } | 58 } |
| 60 bool _equal(double other)native "Double_equal"; | 59 bool _equal(double other)native "Double_equal"; |
| 61 bool _equalToInteger(int other) native "Double_equalToInteger"; | 60 bool _equalToInteger(int other) native "Double_equalToInteger"; |
| 62 bool operator <(num other) { | 61 bool operator <(num other) { |
| 63 return other > this; | 62 return other > this; |
| 64 } | 63 } |
| 65 bool operator >(num other) { | 64 bool operator >(num other) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 return EQUAL; | 263 return EQUAL; |
| 265 } | 264 } |
| 266 } else if (isNaN) { | 265 } else if (isNaN) { |
| 267 return other.isNaN ? EQUAL : GREATER; | 266 return other.isNaN ? EQUAL : GREATER; |
| 268 } else { | 267 } else { |
| 269 // Other is NaN. | 268 // Other is NaN. |
| 270 return LESS; | 269 return LESS; |
| 271 } | 270 } |
| 272 } | 271 } |
| 273 } | 272 } |
| OLD | NEW |