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

chore: document u128 feature #4225

Merged
merged 11 commits into from
Feb 6, 2024
Merged

chore: document u128 feature #4225

merged 11 commits into from
Feb 6, 2024

Conversation

guipublic
Copy link
Contributor

@guipublic guipublic commented Feb 1, 2024

Description

Problem*

Resolves #4142

Summary*

Add documentation for U128

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [Exceptional Case] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 1, 2024
@guipublic guipublic requested a review from a team February 1, 2024 14:52
@kevaundray kevaundray requested a review from a team February 1, 2024 14:53
Copy link
Contributor

github-actions bot commented Feb 1, 2024

@kevaundray kevaundray added this pull request to the merge queue Feb 6, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 6, 2024
@TomAFrench TomAFrench added this pull request to the merge queue Feb 6, 2024
Merged via the queue into master with commit e5cfb4d Feb 6, 2024
33 checks passed
@TomAFrench TomAFrench deleted the gd/issue_4142 branch February 6, 2024 18:41
@Savio-Sou
Copy link
Collaborator

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Collaborator

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 uints is less performant than working with Fields.

This section reads like performance costs would rank as U128 > native uint > Field.
Is that the correct way to understand it?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Document u128
6 participants