| 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 fixnum; | 5 part of fixnum; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A fixed-precision integer. | 8 * A fixed-precision integer. |
| 9 */ | 9 */ |
| 10 abstract class intx implements Comparable { | 10 abstract class IntX implements Comparable { |
| 11 | 11 |
| 12 // Arithmetic operations. | 12 // Arithmetic operations. |
| 13 intx operator +(other); | 13 IntX operator +(other); |
| 14 intx operator -(other); | 14 IntX operator -(other); |
| 15 // The unary '-' operator. Note that -MIN_VALUE will be equal | 15 // The unary '-' operator. Note that -MIN_VALUE will be equal |
| 16 // to MIN_VALUE due to overflow. | 16 // to MIN_VALUE due to overflow. |
| 17 intx operator -(); | 17 IntX operator -(); |
| 18 intx operator *(other); | 18 IntX operator *(other); |
| 19 intx operator %(other); | 19 IntX operator %(other); |
| 20 // Truncating division. | 20 // Truncating division. |
| 21 intx operator ~/(other); | 21 IntX operator ~/(other); |
| 22 intx remainder(other); | 22 IntX remainder(other); |
| 23 | 23 |
| 24 // Note: no / operator | 24 // Note: no / operator |
| 25 | 25 |
| 26 // Bit-operations. | 26 // Bit-operations. |
| 27 intx operator &(other); | 27 IntX operator &(other); |
| 28 intx operator |(other); | 28 IntX operator |(other); |
| 29 intx operator ^(other); | 29 IntX operator ^(other); |
| 30 intx operator ~(); | 30 IntX operator ~(); |
| 31 intx operator <<(int shiftAmount); | 31 IntX operator <<(int shiftAmount); |
| 32 intx operator >>(int shiftAmount); | 32 IntX operator >>(int shiftAmount); |
| 33 intx shiftRightUnsigned(int shiftAmount); | 33 IntX shiftRightUnsigned(int shiftAmount); |
| 34 | 34 |
| 35 // Relational operations, may be applied to intx or int. | 35 // Relational operations, may be applied to IntX or int. |
| 36 int compareTo(Comparable other); | 36 int compareTo(Comparable other); |
| 37 bool operator ==(other); | 37 bool operator ==(other); |
| 38 bool operator <(other); | 38 bool operator <(other); |
| 39 bool operator <=(other); | 39 bool operator <=(other); |
| 40 bool operator >(other); | 40 bool operator >(other); |
| 41 bool operator >=(other); | 41 bool operator >=(other); |
| 42 | 42 |
| 43 // Testers. | 43 // Testers. |
| 44 bool get isEven; | 44 bool get isEven; |
| 45 bool get isMaxValue; | 45 bool get isMaxValue; |
| 46 bool get isMinValue; | 46 bool get isMinValue; |
| 47 bool get isNegative; | 47 bool get isNegative; |
| 48 bool get isOdd; | 48 bool get isOdd; |
| 49 bool get isZero; | 49 bool get isZero; |
| 50 | 50 |
| 51 int get hashCode; | 51 int get hashCode; |
| 52 | 52 |
| 53 intx abs(); | 53 IntX abs(); |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Returns the number of leading zeros in this [intx] as an [int] | 56 * Returns the number of leading zeros in this [IntX] as an [int] |
| 57 * between 0 and 64. | 57 * between 0 and 64. |
| 58 */ | 58 */ |
| 59 int numberOfLeadingZeros(); | 59 int numberOfLeadingZeros(); |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * Returns the number of trailing zeros in this [intx] as an [int] | 62 * Returns the number of trailing zeros in this [IntX] as an [int] |
| 63 * between 0 and 64. | 63 * between 0 and 64. |
| 64 */ | 64 */ |
| 65 int numberOfTrailingZeros(); | 65 int numberOfTrailingZeros(); |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Converts this [intx] to a [List] of [int], starting with the least | 68 * Converts this [IntX] to a [List] of [int], starting with the least |
| 69 * significant byte. | 69 * significant byte. |
| 70 */ | 70 */ |
| 71 List<int> toBytes(); | 71 List<int> toBytes(); |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Converts this [intx] to an [int]. On some platforms, inputs with large | 74 * Converts this [IntX] to an [int]. On some platforms, inputs with large |
| 75 * absolute values (i.e., > 2^52) may lose some of their low bits. | 75 * absolute values (i.e., > 2^52) may lose some of their low bits. |
| 76 */ | 76 */ |
| 77 int toInt(); | 77 int toInt(); |
| 78 | 78 |
| 79 /** | 79 /** |
| 80 * Converts an [intx] to 32 bits. Narrower values are sign extended and | 80 * Converts an [IntX] to 32 bits. Narrower values are sign extended and |
| 81 * wider values have their high bits truncated. | 81 * wider values have their high bits truncated. |
| 82 */ | 82 */ |
| 83 int32 toInt32(); | 83 Int32 toInt32(); |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Converts an [intx] to 64 bits. | 86 * Converts an [IntX] to 64 bits. |
| 87 */ | 87 */ |
| 88 int64 toInt64(); | 88 Int64 toInt64(); |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * Returns the value of this [intx] as a decimal [String]. | 91 * Returns the value of this [IntX] as a decimal [String]. |
| 92 */ | 92 */ |
| 93 String toString(); | 93 String toString(); |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * Returns the value of this [intx] as a hexadecimal [String]. | 96 * Returns the value of this [IntX] as a hexadecimal [String]. |
| 97 */ | 97 */ |
| 98 String toHexString(); | 98 String toHexString(); |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * Returns the value of this [intx] as a [String] in the given radix. | 101 * Returns the value of this [IntX] as a [String] in the given radix. |
| 102 * [radix] must be an integer between 2 and 16, inclusive. | 102 * [radix] must be an integer between 2 and 16, inclusive. |
| 103 */ | 103 */ |
| 104 String toRadixString(int radix); | 104 String toRadixString(int radix); |
| 105 } | 105 } |
| OLD | NEW |