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

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

Issue 11417058: Revert "Remove NullPointerException." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | « pkg/unittest/test/matchers_test.dart ('k') | runtime/lib/expando_patch.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 int get hashCode { 8 int get hashCode {
9 try { 9 try {
10 return toInt(); 10 return toInt();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 double floor() native "Double_floor"; 107 double floor() native "Double_floor";
108 double ceil () native "Double_ceil"; 108 double ceil () native "Double_ceil";
109 double truncate() native "Double_truncate"; 109 double truncate() native "Double_truncate";
110 int toInt() native "Double_toInt"; 110 int toInt() native "Double_toInt";
111 double toDouble() { return this; } 111 double toDouble() { return this; }
112 112
113 double pow(num exponent) { 113 double pow(num exponent) {
114 if (exponent == 0) { 114 if (exponent == 0) {
115 return 1.0; // ECMA-262 15.8.2.13 115 return 1.0; // ECMA-262 15.8.2.13
116 } 116 }
117 if (exponent is! num) { 117 // Throw NullPointerException if exponent is null.
118 throw new ArgumentError(null);
119 }
120 double doubleExponent = exponent.toDouble(); 118 double doubleExponent = exponent.toDouble();
121 if (isNaN || exponent.isNaN) { 119 if (isNaN || exponent.isNaN) {
122 return double.NAN; 120 return double.NAN;
123 } 121 }
124 return _pow(doubleExponent); 122 return _pow(doubleExponent);
125 } 123 }
126 double _pow(double exponent) native "Double_pow"; 124 double _pow(double exponent) native "Double_pow";
127 125
128 String toStringAsFixed(int fractionDigits) { 126 String toStringAsFixed(int fractionDigits) {
129 // See ECMAScript-262, 15.7.4.5 for details. 127 // See ECMAScript-262, 15.7.4.5 for details.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return EQUAL; 221 return EQUAL;
224 } 222 }
225 } else if (isNaN) { 223 } else if (isNaN) {
226 return other.isNaN ? EQUAL : GREATER; 224 return other.isNaN ? EQUAL : GREATER;
227 } else { 225 } else {
228 // Other is NaN. 226 // Other is NaN.
229 return LESS; 227 return LESS;
230 } 228 }
231 } 229 }
232 } 230 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/matchers_test.dart ('k') | runtime/lib/expando_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698