Chromium Code Reviews| Index: lib/core/double.dart |
| diff --git a/lib/core/double.dart b/lib/core/double.dart |
| index a1c47d46e510a08f68e8237c4e59f745d0ee1b4c..b6092556eca319b7d35488c32410870c0fc070be 100644 |
| --- a/lib/core/double.dart |
| +++ b/lib/core/double.dart |
| @@ -1,32 +1,74 @@ |
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| -// Dart core library. |
| - |
| // TODO: Convert this abstract class into a concrete class double |
| // that uses the patch class functionality to account for the |
| // different platform implementations. |
| +/** |
| + * Representation of Dart doubles containing double specific constants |
| + * and operations and specializations of operations inherited from |
| + * [num]. |
| + * |
| + * The [double] type is contagious. Operations on [double]s return |
| + * [double] results. |
| + */ |
| abstract class double extends num { |
| static const double NAN = 0.0 / 0.0; |
| static const double INFINITY = 1.0 / 0.0; |
| static const double NEGATIVE_INFINITY = -INFINITY; |
| - // Specialization of super-interface. Double is contagious. We can therefore |
| - // specialize more methods than in other num sub-interfaces. |
| + /** Return the remainder from dividing this [double] by [other]. */ |
| abstract double remainder(num other); |
| + |
| + /** Addition operator. */ |
| abstract double operator +(num other); |
| + |
| + /** Subtraction operator. */ |
| abstract double operator -(num other); |
| + |
| + /** Multiplication operator. */ |
| abstract double operator *(num other); |
| + |
| + /** Euclidean modulo operator. */ |
| abstract double operator %(num other); |
| + |
| + /** Division operator. */ |
| abstract double operator /(num other); |
| + |
| + /** |
| + * Truncating division operator. |
| + * |
| + * The result of the truncating division [:a ~/ b:] is equivalent to |
| + * [:(a / b).truncate():]. |
| + */ |
| abstract double operator ~/(num other); |
| + |
| + /** Negate operator. */ |
| abstract double operator -(); |
| + |
| + /** Returns the absolute value of this [double]. */ |
| abstract double abs(); |
| + |
| + /** |
| + * Returns the integer value closest to this [double]. |
| + * |
| + * Rounds away from zero when there is no closest integer: |
| + * [:(3.5).round() == 4:] and [:(-3.5).round() == -4:]. |
|
floitsch
2012/09/24 15:56:14
You should also note what happens for the range ]-
Lasse Reichstein Nielsen
2012/09/24 17:56:42
If the return type is double, I think -0.0 is the
floitsch
2012/09/24 20:17:27
good point. I had thought a lot about this, and ii
|
| + */ |
| abstract double round(); |
| + |
| + /** Returns the greatest integer value no greater than this [double]. */ |
| abstract double floor(); |
| + |
| + /** Returns the least integer value that is no smaller than this [double]. */ |
|
floitsch
2012/09/24 15:56:14
ditto.
|
| abstract double ceil(); |
| + |
| + /** |
| + * Returns the integer value obtained by discarding any fractional |
| + * digits from this [double]. |
| + */ |
| abstract double truncate(); |
| /** |
| @@ -50,8 +92,9 @@ abstract class double extends num { |
| * Accepts the same format as double literals: |
| * [: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+] :] |
| * |
| - * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and returns the |
| - * corresponding double value. |
| + * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and |
| + * returns the corresponding double value. |
| + * |
| * Throws a [FormatException] if [source] is not a valid double literal. |
| */ |
| external static double parse(String source); |