Skip to content

Instantly share code, notes, and snippets.

@veridelisi
Last active March 3, 2023 14:14
Show Gist options
  • Save veridelisi/51e7985b6a894d6c17ccfcb5b7854b1d to your computer and use it in GitHub Desktop.
Save veridelisi/51e7985b6a894d6c17ccfcb5b7854b1d to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
contract Shifting {
function right(uint256 x) public pure returns(uint256 y) {
return y = x >> 1; // divide 2
}
function left(uint256 x) public pure returns(uint256 y) {
return y= x << 1; // multiply 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment