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

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

Issue 11415028: Remove NullPointerException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed VM bugs. 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
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 // Throw NullPointerException if exponent is null. 117 if (exponent is! num) {
118 throw new ArgumentError(null);
119 }
118 double doubleExponent = exponent.toDouble(); 120 double doubleExponent = exponent.toDouble();
119 if (isNaN || exponent.isNaN) { 121 if (isNaN || exponent.isNaN) {
120 return double.NAN; 122 return double.NAN;
121 } 123 }
122 return _pow(doubleExponent); 124 return _pow(doubleExponent);
123 } 125 }
124 double _pow(double exponent) native "Double_pow"; 126 double _pow(double exponent) native "Double_pow";
125 127
126 String toStringAsFixed(int fractionDigits) { 128 String toStringAsFixed(int fractionDigits) {
127 // See ECMAScript-262, 15.7.4.5 for details. 129 // See ECMAScript-262, 15.7.4.5 for details.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return EQUAL; 223 return EQUAL;
222 } 224 }
223 } else if (isNaN) { 225 } else if (isNaN) {
224 return other.isNaN ? EQUAL : GREATER; 226 return other.isNaN ? EQUAL : GREATER;
225 } else { 227 } else {
226 // Other is NaN. 228 // Other is NaN.
227 return LESS; 229 return LESS;
228 } 230 }
229 } 231 }
230 } 232 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698