Dart Documentationfixnumintx

intx abstract class

A fixed-precision integer.

abstract class intx implements Comparable {

 // Arithmetic operations.
 intx operator +(other);
 intx operator -(other);
 // The unary '-' operator.  Note that -MIN_VALUE will be equal
 // to MIN_VALUE due to overflow.
 intx operator -();
 intx operator *(other);
 intx operator %(other);
 // Truncating division.
 intx operator ~/(other);
 intx remainder(other);

 // Note: no / operator

 // Bit-operations.
 intx operator &(other);
 intx operator |(other);
 intx operator ^(other);
 intx operator ~();
 intx operator <<(int shiftAmount);
 intx operator >>(int shiftAmount);
 intx shiftRightUnsigned(int shiftAmount);

 // Relational operations, may be applied to intx or int.
 int compareTo(Comparable other);
 bool operator ==(other);
 bool operator <(other);
 bool operator <=(other);
 bool operator >(other);
 bool operator >=(other);

 // Testers.
 bool isEven();
 bool isMaxValue();
 bool isMinValue();
 bool isNegative();
 bool isOdd();
 bool isZero();

 int get hashCode;

 intx abs();

 /**
  * Returns the number of leading zeros in this [intx] as an [int]
  * between 0 and 64.
  */
 int numberOfLeadingZeros();

 /**
  * Returns the number of trailing zeros in this [intx] as an [int]
  * between 0 and 64.
  */
 int numberOfTrailingZeros();

 /**
  * Converts this [intx] to a [List] of [int], starting with the least
  * significant byte.
  */
 List<int> toBytes();

 /**
  * Converts this [intx] to an [int].  On some platforms, inputs with large
  * absolute values (i.e., > 2^52) may lose some of their low bits.
  */
 int toInt();

 /**
  * Converts an [intx] to 32 bits.  Narrower values are sign extended and
  * wider values have their high bits truncated.
  */
 int32 toInt32();

 /**
  * Converts an [intx] to 64 bits.
  */
 int64 toInt64();

 /**
  * Returns the value of this [intx] as a decimal [String].
  */
 String toString();

 /**
  * Returns the value of this [intx] as a hexadecimal [String].
  */
 String toHexString();

 /**
  * Returns the value of this [intx] as a [String] in the given radix.
  * [radix] must be an integer between 2 and 16, inclusive.
  */
 String toRadixString(int radix);
}

Subclasses

int32, int64

Implements

Comparable

Properties

final int hashCode #

Get a hash code for this object.

All objects have hash codes. Hash codes are guaranteed to be the same for objects that are equal when compared using the equality operator ==. Other than that there are no guarantees about the hash codes. They will not be consistent between runs and there are no distribution guarantees.

If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.

docs inherited from Object
int get hashCode;

Operators

abstract intx operator +(other) #

abstract intx operator -() #

abstract intx operator -(other) #

abstract intx operator *(other) #

abstract intx operator ~/(other) #

abstract intx operator %(other) #

abstract intx operator &(other) #

abstract intx operator |(other) #

abstract intx operator ^(other) #

abstract intx operator ~() #

abstract intx operator <<(int shiftAmount) #

abstract intx operator >>(int shiftAmount) #

abstract bool operator <(other) #

abstract bool operator <=(other) #

abstract bool operator >(other) #

abstract bool operator >=(other) #

abstract bool operator ==(other) #

The equality operator.

The default behavior for all Objects is to return true if and only if this and other are the same object.

Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw or return null.

  • Reflexive: For all objects o, o == o must be true.

  • Symmetric: For all objects o1 and o2, o1 == o2 and o2 == o1 must either both be true, or both be false.

  • Transitive: For all objects o1, o2, and o3, if o1 == o2 and o2 == o3 are true, then o1 == o3 must be true.

The method should also be consistent over time, so equality of two objects should not change over time, or at least only change if one of the objects was modified.

If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.

docs inherited from Object

Methods

abstract intx abs() #

abstract int compareTo(Comparable other) #

Compares this object to another Comparable

Returns a value like a Comparator when comparing this to other.

May throw an ArgumentError if other is of a type that is not comparable to this.

docs inherited from Comparable

abstract bool isEven() #

abstract bool isMaxValue() #

abstract bool isMinValue() #

abstract bool isNegative() #

abstract bool isOdd() #

abstract bool isZero() #

abstract int numberOfLeadingZeros() #

Returns the number of leading zeros in this intx as an int between 0 and 64.

abstract int numberOfTrailingZeros() #

Returns the number of trailing zeros in this intx as an int between 0 and 64.

abstract intx remainder(other) #

abstract intx shiftRightUnsigned(int shiftAmount) #

abstract List<int> toBytes() #

Converts this intx to a List of int, starting with the least significant byte.

abstract String toHexString() #

Returns the value of this intx as a hexadecimal String.

abstract int toInt() #

Converts this intx to an int. On some platforms, inputs with large absolute values (i.e., > 2^52) may lose some of their low bits.

abstract int32 toInt32() #

Converts an intx to 32 bits. Narrower values are sign extended and wider values have their high bits truncated.

abstract int64 toInt64() #

Converts an intx to 64 bits.

abstract String toRadixString(int radix) #

Returns the value of this intx as a String in the given radix. radix must be an integer between 2 and 16, inclusive.

abstract String toString() #

Returns the value of this intx as a decimal String.