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 implements double { | 5 class _Double 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 double _moduloFromInteger(int other) { | 85 double _moduloFromInteger(int other) { |
| 86 return new _Double.fromInteger(other)._modulo(this); | 86 return new _Double.fromInteger(other)._modulo(this); |
| 87 } | 87 } |
| 88 double _remainderFromInteger(int other) { | 88 double _remainderFromInteger(int other) { |
| 89 return new _Double.fromInteger(other)._remainder(this); | 89 return new _Double.fromInteger(other)._remainder(this); |
| 90 } | 90 } |
| 91 bool _greaterThanFromInteger(int other) | 91 bool _greaterThanFromInteger(int other) |
| 92 native "Double_greaterThanFromInteger"; | 92 native "Double_greaterThanFromInteger"; |
| 93 | 93 |
| 94 bool get isNegative native "Double_getIsNegative"; | 94 bool get isNegative native "Double_getIsNegative"; |
| 95 bool get isInfinite native "Double_getIsInfinite"; | 95 bool get isInfinite => _isInfinite; |
|
Florian Schneider
2016/10/18 20:34:20
Why must these be private getters?
zra
2016/10/18 22:36:32
Done.
| |
| 96 bool get isNaN native "Double_getIsNaN"; | 96 bool get _isInfinite native "Double_getIsInfinite"; |
| 97 bool get isNaN => _isNaN; | |
| 98 bool get _isNaN native "Double_getIsNaN"; | |
| 97 bool get isFinite => !isInfinite && !isNaN; // Can be optimized. | 99 bool get isFinite => !isInfinite && !isNaN; // Can be optimized. |
| 98 | 100 |
| 99 double abs() { | 101 double abs() { |
| 100 // Handle negative 0.0. | 102 // Handle negative 0.0. |
| 101 if (this == 0.0) return 0.0; | 103 if (this == 0.0) return 0.0; |
| 102 return this < 0.0 ? -this : this; | 104 return this < 0.0 ? -this : this; |
| 103 } | 105 } |
| 104 | 106 |
| 105 double get sign { | 107 double get sign { |
| 106 if (this > 0.0) return 1.0; | 108 if (this > 0.0) return 1.0; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 } | 280 } |
| 279 } | 281 } |
| 280 | 282 |
| 281 static const int _FRACTIONAL_BITS = // Bits to keep after the decimal point. | 283 static const int _FRACTIONAL_BITS = // Bits to keep after the decimal point. |
| 282 const int.fromEnvironment("doubleFractionalBits", defaultValue: 20); | 284 const int.fromEnvironment("doubleFractionalBits", defaultValue: 20); |
| 283 static const double _BIAS = 1.5 * (1 << (52 - _FRACTIONAL_BITS)); | 285 static const double _BIAS = 1.5 * (1 << (52 - _FRACTIONAL_BITS)); |
| 284 | 286 |
| 285 // Returns this with only _FRACTIONAL_BITS bits after the decimal point. | 287 // Returns this with only _FRACTIONAL_BITS bits after the decimal point. |
| 286 double get p => this + _BIAS - _BIAS; | 288 double get p => this + _BIAS - _BIAS; |
| 287 } | 289 } |
| OLD | NEW |