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 u16/32/64 #206

Merged
merged 6 commits into from
Oct 24, 2024
Merged

Add u16/32/64 #206

merged 6 commits into from
Oct 24, 2024

Conversation

katat
Copy link
Collaborator

@katat katat commented Oct 18, 2024

  • Add builtin types: u16/32/64

  • Increate test coverage for these newly added stdlib

@katat katat requested a review from gio54321 October 18, 2024 06:56
@katat katat mentioned this pull request Oct 18, 2024
2 tasks
let bit_len = 32;

// range check
let ignore_ = bits::to_bits(bit_len, val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually the syntax is let _ = or let _bits =

Copy link
Collaborator Author

@katat katat Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current rule doesn't allow starting with _, maybe it is time to change this rule?

}

fn Uint64.less_eq_than(self, rhs: Uint64) -> Bool {
return comparator::less_eq_than(self.bit_len, self.inner, rhs.inner);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also implement add, sub, etc.
this is when having a bit_len field would be interesting... because theoretically we could track how many bits max the result of an operation is, and only trigger a range check when we might be above 8 bits for u8. But in the absence of that we can simply perform a range check after every operation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To take it further, maybe we can make it support builtin operations, such as + -, by mapping these operations to these functions. #214

Copy link
Contributor

@mimoo mimoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@katat katat changed the base branch from fix/struct-cst to feat/init-stdlib October 24, 2024 06:26
@katat katat merged commit 3f91646 into feat/init-stdlib Oct 24, 2024
1 check failed
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.

2 participants