Add arithmetic shift, use logic shift in current right shift (#1670)
* Add arithmetic shift, use logic shift in current * State that the MSBs will be cleared to zero in logic right shift
This commit is contained in:
1 parent
c2ef75df6d
commit
06bdbdaed2
2 files changed
+6
-2
No files matched your search
@@ -308,7 +308,10 @@ only take integer values, so if the input has a decimal part, it will be discard
|
|||||||
tend to -1.
|
tend to -1.
|
||||||
- `bitwise_shift_left(num, amount)` -> Shifts all the bits of the first number `amount` spots to the left. Note that shifting more
|
- `bitwise_shift_left(num, amount)` -> Shifts all the bits of the first number `amount` spots to the left. Note that shifting more
|
||||||
than 63 positions will result in a 0 (cos you shift out all the bits of the number)
|
than 63 positions will result in a 0 (cos you shift out all the bits of the number)
|
||||||
- `bitwise_shift_right(num, amount)` -> Shifts all the bits of the first number `amount` spots to the right. Like with the above,
|
- `bitwise_shift_right(num, amount)` -> Shifts all the bits of the first number `amount` spots to the right logically. That is, the
|
||||||
|
`amount` most significant bits will always be set to 0. Like with the above, shifting more than 63 bits results in a 0.
|
||||||
|
- `bitwise_arithmetic_shift_right(num, amount)` -> Shifts all the bits of the first number `amount` spots to the right arithmetically.
|
||||||
|
That is, if the most significant (sign) bit is a 1, it'll propagate the one to the `amount` most significant bits. Like with the above,
|
||||||
shifting more than 63 bits results in a 0.
|
shifting more than 63 bits results in a 0.
|
||||||
- `bitwise_roll_left(num, amount)` -> Rolls the bits of the first number `amount` bits to the left. This is basically where you
|
- `bitwise_roll_left(num, amount)` -> Rolls the bits of the first number `amount` bits to the left. This is basically where you
|
||||||
shift out the first `amount` bits and then add them on at the back, essentially 'rolling' the number. Note that unlike with
|
shift out the first `amount` bits and then add them on at the back, essentially 'rolling' the number. Note that unlike with
|
||||||
|
|||||||
@@ -314,7 +314,8 @@ public class Operators
|
|||||||
});
|
});
|
||||||
expression.addFunctionalEquivalence("<=", "nondecreasing");
|
expression.addFunctionalEquivalence("<=", "nondecreasing");
|
||||||
expression.addMathematicalBinaryIntFunction("bitwise_shift_left", (num, amount) -> num << amount);
|
expression.addMathematicalBinaryIntFunction("bitwise_shift_left", (num, amount) -> num << amount);
|
||||||
expression.addMathematicalBinaryIntFunction("bitwise_shift_right", (num, amount) -> num >> amount);
|
expression.addMathematicalBinaryIntFunction("bitwise_shift_right", (num, amount) -> num >>> amount);
|
||||||
|
expression.addMathematicalBinaryIntFunction("bitwise_arithmetic_shift_right", (num, amount) -> num >> amount);
|
||||||
expression.addMathematicalBinaryIntFunction("bitwise_roll_left", (num, amount) -> Long.rotateLeft(num, (int)amount));
|
expression.addMathematicalBinaryIntFunction("bitwise_roll_left", (num, amount) -> Long.rotateLeft(num, (int)amount));
|
||||||
expression.addMathematicalBinaryIntFunction("bitwise_roll_right", (num, amount) -> Long.rotateRight(num, (int)amount));
|
expression.addMathematicalBinaryIntFunction("bitwise_roll_right", (num, amount) -> Long.rotateRight(num, (int)amount));
|
||||||
expression.addMathematicalUnaryIntFunction("bitwise_not", d -> {
|
expression.addMathematicalUnaryIntFunction("bitwise_not", d -> {
|
||||||
|
|||||||
Reference in new issue
Block a user