toUnsigned method

  1. @override
Int64 toUnsigned(
  1. int width
)
override

Returns the least significant width bits of this integer as a non-negative number (i.e. unsigned representation). The returned value has zeros in all bit positions higher than width.

If the input fits in width bits without truncation, the result is the same as the input. The minimum width needed to avoid truncation of x is given by x.bitLength, i.e.

x == x.toUnsigned(x.bitLength);

Implementation

@override
Int64 toUnsigned(int width) {
  if (width < 0 || width > 64) throw RangeError.range(width, 0, 64);
  if (width > _BITS01) {
    int h = _h.toUnsigned(width - _BITS01);
    return Int64._masked(_l, _m, h);
  } else if (width > _BITS) {
    int m = _m.toUnsigned(width - _BITS);
    return Int64._masked(_l, m, 0);
  } else {
    int l = _l.toUnsigned(width);
    return Int64._masked(l, 0, 0);
  }
}