| 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 * All numbers in dart are instances of [num]. | 8 * All numbers in dart are instances of [num]. |
| 9 */ | 9 */ |
| 10 abstract class num implements Comparable<num> { | 10 abstract class num implements Comparable<num> { |
| 11 /** Addition operator. */ | 11 /** Addition operator. */ |
| 12 num operator +(num other); | 12 num operator +(num other); |
| 13 | 13 |
| 14 /** Subtraction operator. */ | 14 /** Subtraction operator. */ |
| 15 num operator -(num other); | 15 num operator -(num other); |
| 16 | 16 |
| 17 /** Multiplication operator. */ | 17 /** Multiplication operator. */ |
| 18 num operator *(num other); | 18 num operator *(num other); |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * Euclidean modulo operator. | 21 * Euclidean modulo operator. |
| 22 * | 22 * |
| 23 * Returns the remainder of the euclidean division. The euclidean division of | 23 * Returns the remainder of the euclidean division. The euclidean division of |
| 24 * two integers `a` and `b` yields two integers `q` and `r` such that | 24 * two integers `a` and `b` yields two integers `q` and `r` such that |
| 25 * `a = b*q + r` and `0 <= r < |a|`. | 25 * `a == b*q + r` and `0 <= r < a.abs()`. |
| 26 * | 26 * |
| 27 * The euclidean division is only defined for integers, but can be easily | 27 * The euclidean division is only defined for integers, but can be easily |
| 28 * extended to work with doubles. In that case `r` may have a non-integer | 28 * extended to work with doubles. In that case `r` may have a non-integer |
| 29 * value, but it still verifies `0 <= r < |a|`. | 29 * value, but it still verifies `0 <= r < |a|`. |
| 30 * | 30 * |
| 31 * The sign of the returned value `r` is always positive. | 31 * The sign of the returned value `r` is always positive. |
| 32 * | 32 * |
| 33 * See [remainder] for the remainder of the truncating division. | 33 * See [remainder] for the remainder of the truncating division. |
| 34 */ | 34 */ |
| 35 num operator %(num other); | 35 num operator %(num other); |
| 36 | 36 |
| 37 /** Division operator. */ | 37 /** Division operator. */ |
| 38 double operator /(num other); | 38 double operator /(num other); |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * Truncating division operator. | 41 * Truncating division operator. |
| 42 * | 42 * |
| 43 * If either operand is a [double] then the result of the truncating division | 43 * If either operand is a [double] then the result of the truncating division |
| 44 * [:a ~/ b:] is equivalent to [:(a / b).truncate().toInt():]. | 44 * [:a ~/ b:] is equivalent to [:(a / b).truncate().toInt():]. |
| 45 * | 45 * |
| 46 * If both operands are [int]s then [:a ~/ b:] performs the truncating | 46 * If both operands are [int]s then [:a ~/ b:] performs the truncating |
| 47 * integer division. | 47 * integer division. |
| 48 */ | 48 */ |
| 49 int operator ~/(num other); | 49 int operator ~/(num other); |
| 50 | 50 |
| 51 /** Negate operator. */ | 51 /** Negate operator. */ |
| 52 num operator -(); | 52 num operator -(); |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Return the remainder of the truncating division of `this` by [other]. | 55 * Returns the remainder of the truncating division of `this` by [other]. |
| 56 * | 56 * |
| 57 * The result `r` of this operation satisfies: `this = this ~/ other + r`. | 57 * The result `r` of this operation satisfies: `this == this ~/ other + r`. |
| 58 * As a consequence the remainder `r` has the same sign as the dividend | 58 * As a consequence the remainder `r` has the same sign as the dividend |
| 59 * `this`. | 59 * `this`. |
| 60 */ | 60 */ |
| 61 num remainder(num other); | 61 num remainder(num other); |
| 62 | 62 |
| 63 /** Relational less than operator. */ | 63 /** Relational less than operator. */ |
| 64 bool operator <(num other); | 64 bool operator <(num other); |
| 65 | 65 |
| 66 /** Relational less than or equal operator. */ | 66 /** Relational less than or equal operator. */ |
| 67 bool operator <=(num other); | 67 bool operator <=(num other); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 /** | 158 /** |
| 159 * Return this [num] as a [double]. | 159 * Return this [num] as a [double]. |
| 160 * | 160 * |
| 161 * If the number is not representable as a [double], an | 161 * If the number is not representable as a [double], an |
| 162 * approximation is returned. For numerically large integers, the | 162 * approximation is returned. For numerically large integers, the |
| 163 * approximation may be infinite. | 163 * approximation may be infinite. |
| 164 */ | 164 */ |
| 165 double toDouble(); | 165 double toDouble(); |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * Converts [this] to a string representation with [fractionDigits] digits | 168 * Converts [this] to a [double] and then gives string representation with |
| 169 * after the decimal point. | 169 * [fractionDigits] digits after the decimal point. |
| 170 * | 170 * |
| 171 * The parameter [fractionDigits] must be an integer satisfying: | 171 * The parameter [fractionDigits] must be an integer satisfying: |
| 172 * [:0 <= fractionDigits <= 20:]. | 172 * [:0 <= fractionDigits <= 20:]. |
| 173 */ | 173 */ |
| 174 String toStringAsFixed(int fractionDigits); | 174 String toStringAsFixed(int fractionDigits); |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * Converts [this] to a string in decimal exponential notation with | 177 * Converts [this] to a [double] and then gives a string in decimal |
| 178 * [fractionDigits] digits after the decimal point. | 178 * exponential notation with [fractionDigits] digits after the decimal point. |
| 179 * | 179 * |
| 180 * If [fractionDigits] is given then it must be an integer satisfying: | 180 * If [fractionDigits] is given then it must be an integer satisfying: |
| 181 * [:0 <= fractionDigits <= 20:]. Without the parameter the returned string | 181 * [:0 <= fractionDigits <= 20:]. Without the parameter the returned string |
| 182 * uses the shortest number of digits that accurately represent [this]. | 182 * uses the shortest number of digits that accurately represent [this]. |
| 183 */ | 183 */ |
| 184 String toStringAsExponential([int fractionDigits]); | 184 String toStringAsExponential([int fractionDigits]); |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * Converts [this] to a string representation with [precision] significant | 187 * Converts [this] to a double and gives a string representation with |
| 188 * digits. | 188 * [precision] significant digits. |
| 189 * | 189 * |
| 190 * The parameter [precision] must be an integer satisfying: | 190 * The parameter [precision] must be an integer satisfying: |
| 191 * [:1 <= precision <= 21:]. | 191 * [:1 <= precision <= 21:]. |
| 192 */ | 192 */ |
| 193 String toStringAsPrecision(int precision); | 193 String toStringAsPrecision(int precision); |
| 194 | |
| 195 | |
| 196 } | 194 } |
| OLD | NEW |