OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart core library. | 5 // Dart core library. |
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 |
11 abstract class double implements num { | 11 abstract class double extends num { |
12 static const double NAN = 0.0 / 0.0; | 12 static const double NAN = 0.0 / 0.0; |
13 static const double INFINITY = 1.0 / 0.0; | 13 static const double INFINITY = 1.0 / 0.0; |
14 static const double NEGATIVE_INFINITY = -INFINITY; | 14 static const double NEGATIVE_INFINITY = -INFINITY; |
15 | 15 |
16 // Specialization of super-interface. Double is contagious. We can therefore | 16 // Specialization of super-interface. Double is contagious. We can therefore |
17 // specialize more methods than in other num sub-interfaces. | 17 // specialize more methods than in other num sub-interfaces. |
18 abstract double remainder(num other); | 18 abstract double remainder(num other); |
19 abstract double operator +(num other); | 19 abstract double operator +(num other); |
20 abstract double operator -(num other); | 20 abstract double operator -(num other); |
21 abstract double operator *(num other); | 21 abstract double operator *(num other); |
22 abstract double operator %(num other); | 22 abstract double operator %(num other); |
23 abstract double operator /(num other); | 23 abstract double operator /(num other); |
24 abstract double operator ~/(num other); | 24 abstract double operator ~/(num other); |
25 abstract double operator -(); | 25 abstract double operator -(); |
26 abstract double abs(); | 26 abstract double abs(); |
27 abstract double round(); | 27 abstract double round(); |
28 abstract double floor(); | 28 abstract double floor(); |
29 abstract double ceil(); | 29 abstract double ceil(); |
30 abstract double truncate(); | 30 abstract double truncate(); |
| 31 |
| 32 /** |
| 33 * Provide a representation of this [double] value. |
| 34 * |
| 35 * The representation is a number literal such that the closest double value |
| 36 * to the representation's mathematical value is this [double]. |
| 37 * |
| 38 * Returns "NaN" for the Not-a-Number value. |
| 39 * Returns "Infinity" and "-Infinity" for positive and negative Infinity. |
| 40 * Returns "-0.0" for negative zero. |
| 41 * |
| 42 * It should always be the case that if [:d:] is a [double], then |
| 43 * [:d == double.parse(d.toString()):]. |
| 44 */ |
| 45 abstract String toString(); |
| 46 |
| 47 /** |
| 48 * Parse [source] as an double literal and return its value. |
| 49 * |
| 50 * Accepts the same format as double literals: |
| 51 * [: ['+'|'-'] [digit* '.'] digit+ [('e'|'E') ['+'|'-'] digit+] :] |
| 52 * |
| 53 * Also recognizes "NaN", "Infinity" and "-Infinity" as inputs and returns the |
| 54 * corresponding double value. |
| 55 * Throws a [FormatException] if [source] is not a valid double literal. |
| 56 */ |
| 57 external static double parse(String source); |
31 } | 58 } |
OLD | NEW |