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

Side by Side Diff: sdk/lib/_internal/lib/js_number.dart

Issue 28973002: Add isFinite getter to num. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
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 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler 8 * The super interceptor class for [JSInt] and [JSDouble]. The compiler
9 * recognizes this class as an interceptor, and changes references to 9 * recognizes this class as an interceptor, and changes references to
10 * [:this:] to actually use the receiver of the method, which is 10 * [:this:] to actually use the receiver of the method, which is
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 bool get isNegative => (this == 0) ? (1 / this) < 0 : this < 0; 43 bool get isNegative => (this == 0) ? (1 / this) < 0 : this < 0;
44 44
45 bool get isNaN => JS('bool', r'isNaN(#)', this); 45 bool get isNaN => JS('bool', r'isNaN(#)', this);
46 46
47 bool get isInfinite { 47 bool get isInfinite {
48 return JS('bool', r'# == Infinity', this) 48 return JS('bool', r'# == Infinity', this)
49 || JS('bool', r'# == -Infinity', this); 49 || JS('bool', r'# == -Infinity', this);
50 } 50 }
51 51
52 bool get isFinite => JS('bool', r'isFinite(#)', this);
53
52 num remainder(num b) { 54 num remainder(num b) {
53 checkNull(b); // TODO(ngeoffray): This is not specified but co19 tests it. 55 checkNull(b); // TODO(ngeoffray): This is not specified but co19 tests it.
54 if (b is! num) throw new ArgumentError(b); 56 if (b is! num) throw new ArgumentError(b);
55 return JS('num', r'# % #', this, b); 57 return JS('num', r'# % #', this, b);
56 } 58 }
57 59
58 num abs() => JS('num', r'Math.abs(#)', this); 60 num abs() => JS('num', r'Math.abs(#)', this);
59 61
60 int toInt() { 62 int toInt() {
61 if (isNaN) throw new UnsupportedError('NaN'); 63 if (isNaN) throw new UnsupportedError('NaN');
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 341
340 Type get runtimeType => int; 342 Type get runtimeType => int;
341 343
342 int operator ~() => JS('int', r'(~#) >>> 0', this); 344 int operator ~() => JS('int', r'(~#) >>> 0', this);
343 } 345 }
344 346
345 class JSDouble extends JSNumber implements double { 347 class JSDouble extends JSNumber implements double {
346 const JSDouble(); 348 const JSDouble();
347 Type get runtimeType => double; 349 Type get runtimeType => double;
348 } 350 }
OLDNEW
« no previous file with comments | « runtime/lib/integers.dart ('k') | sdk/lib/core/num.dart » ('j') | sdk/lib/core/num.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698