-
Notifications
You must be signed in to change notification settings - Fork 206
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
chore: document u128 feature #4225
Conversation
🚀 Deployed on https://65c270e458b37b1a42b0b029--noir-docs.netlify.app |
cc @noir-lang/developerrelations re doc changes. |
|
||
The built-in structure `U128` allows you to use 128-bit unsigned integers almost like a native integer type. However, there are some differences to keep in mind: | ||
- You cannot cast between a native integer and `U128` | ||
- There is a higher performance cost when using `U128`, compared to a native type. |
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.
Just a question here @guipublic don't all casts to unsigned integers have a performance cost? I was under that impression (because range checks).
Is this cost simply higher than usual? If not, we should maybe point to the performance cost at the top of the page and remove this one to avoid confusion
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.
There is no cast for U128, as explained in the doc, so I am not sure to understand your question.
In term of performance, converting an integer to U128 will have no cost (because U128 is the biggest), and converting to a lower bit size will not have a specific drawback because of U128, just what you should expect.
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.
I guess what @signorecello meant was working with native uint
s is less performant than working with Field
s.
This section reads like performance costs would rank as U128
> native uint
> Field
.
Is that the correct way to understand it?
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.
Yes, the higher the bit size, the higher is the cost. But because U128 uses 2 limbs, cost of arithmetic operations are even higher, especially for multiplication.
Description
Problem*
Resolves #4142
Summary*
Add documentation for U128
Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.