Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: negative to unsigned int conversion #119

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bsh98
Copy link

@bsh98 bsh98 commented Feb 12, 2023

Motivation

Resolves #79

Approach

Added uintN(), a built-in expression macro to convert negative evaluating expressions to positive values. A new expression type Uint was added to account for the case when the expression needs to be evaluated with context (e.g. user-defined macro). Any feedback is greatly appreciated!

Example

push1 uint8(-1) evaluates to 0x60ff.

Alternatives

It may be a bit cleaner to just add built-in macros for max unsigned integer values (e.g. max_uint256()). I could also see some benefit to implementing bitwise operators (e.g. 1 << 256). However, the current approach also allows for representing negative integers in two's-compliment, which could be of value.

todo

Will update docs if changes are deemed appropriate.

@bsh98 bsh98 changed the title feat: negative to unsigned int conversion (resolves #79) feat: negative to unsigned int conversion Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explict Conversion from negative value to unsigned integer
1 participant