operator >> method
Shift the bits of this integer to the right by shiftAmount
.
Shifting to the right makes the number smaller and drops the least
significant bits, effectively doing an integer division by
pow(2, shiftIndex)
.
It is an error if shiftAmount
is negative.
Example:
print((Obj(3) >> Obj(1)).toRadixString(2)); // 0011 -> 0001
print((Obj(9) >> Obj(2)).toRadixString(2)); // 1001 -> 0010
print((Obj(10) >> Obj(3)).toRadixString(2)); // 1010 -> 0001
print((Obj(-6) >> Obj(2)).toRadixString); // 111...1010 -> 111...1110 == -2
print((Obj(-85) >> Obj(3)).toRadixString); // 111...10101011 -> 111...11110101 == -11
Implementation
Obj<int> operator >>(Obj<int> shiftAmount) =>
(value >> shiftAmount.value).obj;