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

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

Issue 11361190: a === b -> identical(a, b) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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 | « runtime/lib/date_patch.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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 String _toStringAsFixed(int fractionDigits) native "Double_toStringAsFixed"; 150 String _toStringAsFixed(int fractionDigits) native "Double_toStringAsFixed";
151 151
152 String toStringAsExponential(int fractionDigits) { 152 String toStringAsExponential(int fractionDigits) {
153 // See ECMAScript-262, 15.7.4.6 for details. 153 // See ECMAScript-262, 15.7.4.6 for details.
154 154
155 // The EcmaScript specification checks for NaN and Infinity before looking 155 // The EcmaScript specification checks for NaN and Infinity before looking
156 // at the fractionDigits. In Dart we are consistent with toStringAsFixed and 156 // at the fractionDigits. In Dart we are consistent with toStringAsFixed and
157 // look at the fractionDigits first. 157 // look at the fractionDigits first.
158 158
159 // Step 7. 159 // Step 7.
160 if (fractionDigits !== null && 160 if (fractionDigits != null &&
161 (fractionDigits < 0 || fractionDigits > 20)) { 161 (fractionDigits < 0 || fractionDigits > 20)) {
162 // TODO(antonm): should be proper RangeError or Dart counterpart. 162 // TODO(antonm): should be proper RangeError or Dart counterpart.
163 throw "Range error"; 163 throw "Range error";
164 } 164 }
165 165
166 if (isNaN) return "NaN"; 166 if (isNaN) return "NaN";
167 if (this == double.INFINITY) return "Infinity"; 167 if (this == double.INFINITY) return "Infinity";
168 if (this == -double.INFINITY) return "-Infinity"; 168 if (this == -double.INFINITY) return "-Infinity";
169 169
170 // The dart function prints the shortest representation when fractionDigits 170 // The dart function prints the shortest representation when fractionDigits
171 // equals null. The native function wants -1 instead. 171 // equals null. The native function wants -1 instead.
172 fractionDigits = (fractionDigits === null) ? -1 : fractionDigits; 172 fractionDigits = (fractionDigits == null) ? -1 : fractionDigits;
173 173
174 return _toStringAsExponential(fractionDigits); 174 return _toStringAsExponential(fractionDigits);
175 } 175 }
176 String _toStringAsExponential(int fractionDigits) 176 String _toStringAsExponential(int fractionDigits)
177 native "Double_toStringAsExponential"; 177 native "Double_toStringAsExponential";
178 178
179 String toStringAsPrecision(int precision) { 179 String toStringAsPrecision(int precision) {
180 // See ECMAScript-262, 15.7.4.7 for details. 180 // See ECMAScript-262, 15.7.4.7 for details.
181 181
182 // The EcmaScript specification checks for NaN and Infinity before looking 182 // The EcmaScript specification checks for NaN and Infinity before looking
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 return EQUAL; 221 return EQUAL;
222 } 222 }
223 } else if (isNaN) { 223 } else if (isNaN) {
224 return other.isNaN ? EQUAL : GREATER; 224 return other.isNaN ? EQUAL : GREATER;
225 } else { 225 } else {
226 // Other is NaN. 226 // Other is NaN.
227 return LESS; 227 return LESS;
228 } 228 }
229 } 229 }
230 } 230 }
OLDNEW
« no previous file with comments | « runtime/lib/date_patch.dart ('k') | runtime/lib/expando_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698