this contract not returns a correct value, what's wrong? The MASK don't seems correct, shiftedGroupId
not returns anything
Code to reproduce
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.7.6;
/**
* @title Storage
* @dev Store & retrieve value in a variable
*/
contract Storage {
uint256 public constant GROUP_MASK = uint256(uint128(~0)) << 128;
/**
* @dev Store value in variable
* @param id value to store
*/
function store(uint256 id) public view returns (uint256){
uint256 shiftedGroupId = (id & GROUP_MASK);
uint256 groupId = shiftedGroupId >> 128;
return groupId;
}
}
Environment
remix