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

Add signed to unsigned arithmetic #6

Open
anoushk1234 opened this issue Sep 5, 2024 · 1 comment
Open

Add signed to unsigned arithmetic #6

anoushk1234 opened this issue Sep 5, 2024 · 1 comment

Comments

@anoushk1234
Copy link
Owner

When converting from a signed integer to unsigned integer the value should be 2^(bits)-value

Ex:
signed 32 bit: -1
unsigned 32 bit casted: 2^32 - 1

@anoushk1234 anoushk1234 changed the title Add signed to unsigned arithmatic Add signed to unsigned arithmetic Sep 5, 2024
@anoushk1234
Copy link
Owner Author

Currently sets to max but this is wrong:

if (ix.imm >= 0) {
reg[dst] = @as(u64, @intCast(ix.imm));
} else {
reg[dst] = std.math.maxInt(u64);
}

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

No branches or pull requests

1 participant