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

Side by Side Diff: sdk/lib/core/double.dart

Issue 15333006: Rewrite double.parse. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 7 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 dart.core; 5 part of dart.core;
6 6
7 // TODO: Convert this abstract class into a concrete class double 7 // TODO: Convert this abstract class into a concrete class double
8 // that uses the patch class functionality to account for the 8 // that uses the patch class functionality to account for the
9 // different platform implementations. 9 // different platform implementations.
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 * Returns "-0.0" for negative zero. 126 * Returns "-0.0" for negative zero.
127 * 127 *
128 * It should always be the case that if [:d:] is a [double], then 128 * It should always be the case that if [:d:] is a [double], then
129 * [:d == double.parse(d.toString()):]. 129 * [:d == double.parse(d.toString()):].
130 */ 130 */
131 String toString(); 131 String toString();
132 132
133 /** 133 /**
134 * Parse [source] as an double literal and return its value. 134 * Parse [source] as an double literal and return its value.
135 * 135 *
136 * Accepts the same format as double literals: 136 * Accepts an optional sign followed by either "Infinity",
Lasse Reichstein Nielsen 2013/05/22 08:47:26 .. optional sign (`+` or `-`) immediately followed
floitsch 2013/05/23 02:30:03 Done.
137 * [: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+] :] 137 * "NaN" or a floating-point representation. A floating-point number is
Lasse Reichstein Nielsen 2013/05/22 08:47:26 "floating-point representation", then "floating po
floitsch 2013/05/23 02:30:03 Done.
138 * composed of the mantissa and and optional exponent part. The mantissa is
Lasse Reichstein Nielsen 2013/05/22 08:47:26 "the mantissa" -> "a mantissa" "and and" -> "and a
floitsch 2013/05/23 02:30:03 Done.
139 * either a dot followed by a sequence of digits, or a sequence of digits
Lasse Reichstein Nielsen 2013/05/22 08:47:26 "dot" -> "decimal point (`.`)" "digts" -> "(decima
floitsch 2013/05/23 02:30:03 Done.
140 * optionally followed by a dot and more digits. The (optional) exponent part
Lasse Reichstein Nielsen 2013/05/22 08:47:26 This disallows "4." (which I approve of!) but prob
floitsch 2013/05/23 02:30:03 Changed to "and optionally more digits. Did not re
141 * consists of the character "e" or "E", an optional sign, and the exponent
Lasse Reichstein Nielsen 2013/05/22 08:47:26 "and the exponent digit(s)" -> "and one or more di
floitsch 2013/05/23 02:30:03 Done.
142 * digit(s).
138 * 143 *
139 * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and 144 * The whole string may be surrounded by whitespace.
Lasse Reichstein Nielsen 2013/05/22 08:47:26 Refer to [String.trim] for a definition of "whitep
floitsch 2013/05/23 02:30:03 Changed to: "The input string is trimmed (see [Str
140 * returns the corresponding double value.
141 * 145 *
142 * If the [soure] is not a valid double literal, the [handleError] 146 * If the [source] is not a valid double literal, the [handleError]
143 * is called with the [source] as argument, and its return value is 147 * is called with the [source] as argument, and its return value is
144 * used instead. If no handleError is provided, a [FormatException] 148 * used instead. If no handleError is provided, a [FormatException]
145 * is thrown. 149 * is thrown.
150 *
151 * Examples of accepted strings:
152 *
153 * "3.14"
154 * " 3.14 \xA0"
155 * "0."
156 * ".0"
157 * "-1.e3"
158 * "1234E+7"
159 * "+.12e-9"
160 * "-NaN"
146 */ 161 */
147 external static double parse(String source, 162 external static double parse(String source,
148 [double handleError(String source)]); 163 [double handleError(String source)]);
149 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698