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

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

Issue 28973002: Add isFinite getter to num. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Change comments to not use "whether". Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 double _remainderFromInteger(int other) { 90 double _remainderFromInteger(int other) {
91 return new _Double.fromInteger(other).remainder(this); 91 return new _Double.fromInteger(other).remainder(this);
92 } 92 }
93 bool _greaterThanFromInteger(int other) 93 bool _greaterThanFromInteger(int other)
94 native "Double_greaterThanFromInteger"; 94 native "Double_greaterThanFromInteger";
95 95
96 bool get isNegative native "Double_getIsNegative"; 96 bool get isNegative native "Double_getIsNegative";
97 bool get isInfinite native "Double_getIsInfinite"; 97 bool get isInfinite native "Double_getIsInfinite";
98 bool get isNaN native "Double_getIsNaN"; 98 bool get isNaN native "Double_getIsNaN";
99 bool get isFinite => !isInfinite && !isNaN; // Can be optimized.
99 100
100 double abs() { 101 double abs() {
101 // Handle negative 0.0. 102 // Handle negative 0.0.
102 if (this == 0.0) return 0.0; 103 if (this == 0.0) return 0.0;
103 return this < 0.0 ? -this : this; 104 return this < 0.0 ? -this : this;
104 } 105 }
105 106
106 int round() => roundToDouble().toInt(); 107 int round() => roundToDouble().toInt();
107 int floor() => floorToDouble().toInt(); 108 int floor() => floorToDouble().toInt();
108 int ceil () => ceilToDouble().toInt(); 109 int ceil () => ceilToDouble().toInt();
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return EQUAL; 230 return EQUAL;
230 } 231 }
231 } else if (isNaN) { 232 } else if (isNaN) {
232 return other.isNaN ? EQUAL : GREATER; 233 return other.isNaN ? EQUAL : GREATER;
233 } else { 234 } else {
234 // Other is NaN. 235 // Other is NaN.
235 return LESS; 236 return LESS;
236 } 237 }
237 } 238 }
238 } 239 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698