OLD | NEW |
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 /** | 7 /** |
8 * An integer or floating-point number. | 8 * An integer or floating-point number. |
9 * | 9 * |
10 * It is a compile-time error for any type other than [int] or [double] | 10 * It is a compile-time error for any type other than [int] or [double] |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 * double. | 289 * double. |
290 */ | 290 */ |
291 double truncateToDouble(); | 291 double truncateToDouble(); |
292 | 292 |
293 /** | 293 /** |
294 * Returns this [num] clamped to be in the range [lowerLimit]-[upperLimit]. | 294 * Returns this [num] clamped to be in the range [lowerLimit]-[upperLimit]. |
295 * | 295 * |
296 * The comparison is done using [compareTo] and therefore takes `-0.0` into | 296 * The comparison is done using [compareTo] and therefore takes `-0.0` into |
297 * account. This also implies that [double.NAN] is treated as the maximal | 297 * account. This also implies that [double.NAN] is treated as the maximal |
298 * double value. | 298 * double value. |
| 299 * |
| 300 * The arguments [lowerLimit] and [upperLimit] must form a valid range where |
| 301 * `lowerLimit.compareTo(upperLimit) <= 0`. |
299 */ | 302 */ |
300 num clamp(num lowerLimit, num upperLimit); | 303 num clamp(num lowerLimit, num upperLimit); |
301 | 304 |
302 /** Truncates this [num] to an integer and returns the result as an [int]. */ | 305 /** Truncates this [num] to an integer and returns the result as an [int]. */ |
303 int toInt(); | 306 int toInt(); |
304 | 307 |
305 /** | 308 /** |
306 * Return this [num] as a [double]. | 309 * Return this [num] as a [double]. |
307 * | 310 * |
308 * If the number is not representable as a [double], an | 311 * If the number is not representable as a [double], an |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 result = double.parse(source, _returnDoubleNull); | 447 result = double.parse(source, _returnDoubleNull); |
445 if (result != null) return result; | 448 if (result != null) return result; |
446 if (onError == null) throw new FormatException(input); | 449 if (onError == null) throw new FormatException(input); |
447 return onError(input); | 450 return onError(input); |
448 } | 451 } |
449 | 452 |
450 /** Helper functions for [parse]. */ | 453 /** Helper functions for [parse]. */ |
451 static int _returnIntNull(String _) => null; | 454 static int _returnIntNull(String _) => null; |
452 static double _returnDoubleNull(String _) => null; | 455 static double _returnDoubleNull(String _) => null; |
453 } | 456 } |
OLD | NEW |