You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for the bitwise unary operator ~, the bitwise binary operators &, |, and ^, and the shift operators >> and <<. An example use case can be packing:
@internaldef _pack_1_1(left: bytes1, right: bytes1) ->bytes2:
left = left &convert((max_value(uint256) <<248), bytes1)
right = right &convert((max_value(uint256) <<248), bytes1)
return left | (right >>8)
The text was updated successfully, but these errors were encountered:
i think &, | and ^ are fine. shift operators and inverter operator ~ might be restricted to bytes32. (i guess they also have sane implementations for other bytesM types, but need extra instructions to ensure the rotation/bit cleaning happens correctly).
i think &, | and ^ are fine. shift operators and inverter operator ~ might be restricted to bytes32. (i guess they also have sane implementations for other bytesM types, but need extra instructions to ensure the rotation/bit cleaning happens correctly).
I'm fine with keeping the shift operators and the unary operator ~ to bytes32. The unary operator ~ for non-bytes32 types could be useful for some special use cases around math functions, where you want to get the max value of a type for example, i.e. ~empty(uint64) but since we also have max_value, the ergonomics is not improved by adding ~ to non-bytes32 types for this use case.
Summary
Add support for the bitwise unary operator
~
, the bitwise binary operators&
,|
, and^
, and the shift operators>>
and<<
. An example use case can be packing:The text was updated successfully, but these errors were encountered: