-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add u16/32/64 #206
Conversation
let bit_len = 32; | ||
|
||
// range check | ||
let ignore_ = bits::to_bits(bit_len, val); |
There was a problem hiding this comment.
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 =
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add builtin types: u16/32/64
Increate test coverage for these newly added stdlib