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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 bool _equal(double other) native "Double_equal"; | 56 bool _equal(double other) native "Double_equal"; |
57 bool _equalToInteger(int other) native "Double_equalToInteger"; | 57 bool _equalToInteger(int other) native "Double_equalToInteger"; |
58 bool operator <(num other) { | 58 bool operator <(num other) { |
59 return other > this; | 59 return other > this; |
60 } | 60 } |
61 bool operator >(num other) { | 61 bool operator >(num other) { |
62 return _greaterThan(other.toDouble()); | 62 return _greaterThan(other.toDouble()); |
63 } | 63 } |
64 bool _greaterThan(double other) native "Double_greaterThan"; | 64 bool _greaterThan(double other) native "Double_greaterThan"; |
65 bool operator >=(num other) { | 65 bool operator >=(num other) { |
66 return (this == other) || (this > other); | 66 return (this == other) || (this > other); |
67 } | 67 } |
68 bool operator <=(num other) { | 68 bool operator <=(num other) { |
69 return (this == other) || (this < other); | 69 return (this == other) || (this < other); |
70 } | 70 } |
71 double _addFromInteger(int other) { | 71 double _addFromInteger(int other) { |
72 return new _Double.fromInteger(other) + this; | 72 return new _Double.fromInteger(other)._add(this); |
73 } | 73 } |
74 double _subFromInteger(int other) { | 74 double _subFromInteger(int other) { |
75 return new _Double.fromInteger(other) - this; | 75 return new _Double.fromInteger(other)._sub(this); |
76 } | 76 } |
77 double _mulFromInteger(int other) { | 77 double _mulFromInteger(int other) { |
78 return new _Double.fromInteger(other) * this; | 78 return new _Double.fromInteger(other)._mul(this); |
79 } | 79 } |
80 int _truncDivFromInteger(int other) { | 80 int _truncDivFromInteger(int other) { |
81 return new _Double.fromInteger(other) ~/ this; | 81 return new _Double.fromInteger(other)._trunc_div(this); |
82 } | 82 } |
83 double _moduloFromInteger(int other) { | 83 double _moduloFromInteger(int other) { |
84 return new _Double.fromInteger(other) % this; | 84 return new _Double.fromInteger(other)._modulo(this); |
85 } | 85 } |
86 double _remainderFromInteger(int other) { | 86 double _remainderFromInteger(int other) { |
87 return new _Double.fromInteger(other).remainder(this); | 87 return new _Double.fromInteger(other)._remainder(this); |
88 } | 88 } |
89 bool _greaterThanFromInteger(int other) | 89 bool _greaterThanFromInteger(int other) |
90 native "Double_greaterThanFromInteger"; | 90 native "Double_greaterThanFromInteger"; |
91 | 91 |
92 bool get isNegative native "Double_getIsNegative"; | 92 bool get isNegative native "Double_getIsNegative"; |
93 bool get isInfinite native "Double_getIsInfinite"; | 93 bool get isInfinite native "Double_getIsInfinite"; |
94 bool get isNaN native "Double_getIsNaN"; | 94 bool get isNaN native "Double_getIsNaN"; |
95 bool get isFinite => !isInfinite && !isNaN; // Can be optimized. | 95 bool get isFinite => !isInfinite && !isNaN; // Can be optimized. |
96 | 96 |
97 double abs() { | 97 double abs() { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 return EQUAL; | 262 return EQUAL; |
263 } | 263 } |
264 } else if (isNaN) { | 264 } else if (isNaN) { |
265 return other.isNaN ? EQUAL : GREATER; | 265 return other.isNaN ? EQUAL : GREATER; |
266 } else { | 266 } else { |
267 // Other is NaN. | 267 // Other is NaN. |
268 return LESS; | 268 return LESS; |
269 } | 269 } |
270 } | 270 } |
271 } | 271 } |
OLD | NEW |