Skip to content

feat: negative to unsigned int conversion - #119

Open
bsh98 wants to merge 2 commits into
quilt:masterfrom
bsh98:feat/uint
Open

feat: negative to unsigned int conversion#119
bsh98 wants to merge 2 commits into
quilt:masterfrom
bsh98:feat/uint

Conversation

@bsh98

@bsh98 bsh98 commented Feb 12, 2023

Copy link
Copy Markdown

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