| Index: sdk/lib/_internal/compiler/implementation/lib/js_number.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_number.dart b/sdk/lib/_internal/compiler/implementation/lib/js_number.dart
|
| index a8bfc1333b8be1b9acc85ef456df18b4f925c312..3f6bd427bd86c164da3326ebb3591aae238f0d5c 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/lib/js_number.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/lib/js_number.dart
|
| @@ -41,6 +41,11 @@ class JSNumber implements num {
|
|
|
| bool get isNaN => JS('bool', r'isNaN(#)', this);
|
|
|
| + bool get isInfinite {
|
| + return JS('bool', r'# == Infinity', this)
|
| + || JS('bool', r'# == -Infinity', this);
|
| + }
|
| +
|
| num remainder(num b) {
|
| checkNull(b); // TODO(ngeoffray): This is not specified but co19 tests it.
|
| if (b is! num) throw new ArgumentError(b);
|
| @@ -52,20 +57,20 @@ class JSNumber implements num {
|
| int toInt() {
|
| if (isNaN) throw new UnsupportedError('NaN');
|
| if (isInfinite) throw new UnsupportedError('Infinity');
|
| - num truncated = truncate();
|
| + num truncated = truncateToDouble();
|
| return JS('bool', r'# == -0.0', truncated) ? 0 : truncated;
|
| }
|
|
|
| - num ceil() => JS('num', r'Math.ceil(#)', this);
|
| + int truncate() => toInt();
|
| + int ceil() => ceilToDouble().toInt();
|
| + int floor() => floorToDouble().toInt();
|
| + int round() => roundToDouble().toInt();
|
|
|
| - num floor() => JS('num', r'Math.floor(#)', this);
|
| + double ceilToDouble() => JS('num', r'Math.ceil(#)', this);
|
|
|
| - bool get isInfinite {
|
| - return JS('bool', r'# == Infinity', this)
|
| - || JS('bool', r'# == -Infinity', this);
|
| - }
|
| + double floorToDouble() => JS('num', r'Math.floor(#)', this);
|
|
|
| - num round() {
|
| + double roundToDouble() {
|
| if (this < 0) {
|
| return JS('num', r'-Math.round(-#)', this);
|
| } else {
|
| @@ -73,6 +78,8 @@ class JSNumber implements num {
|
| }
|
| }
|
|
|
| + double truncateToDouble() => this < 0 ? ceilToDouble() : floorToDouble();
|
| +
|
| num clamp(lowerLimit, upperLimit) {
|
| if (lowerLimit is! num) throw new ArgumentError(lowerLimit);
|
| if (upperLimit is! num) throw new ArgumentError(upperLimit);
|
| @@ -86,8 +93,6 @@ class JSNumber implements num {
|
|
|
| double toDouble() => this;
|
|
|
| - num truncate() => this < 0 ? ceil() : floor();
|
| -
|
| String toStringAsFixed(int fractionDigits) {
|
| checkNum(fractionDigits);
|
| // TODO(floitsch): fractionDigits must be an integer.
|
|
|