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

Introduce Big Integers Library #326

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Introduce Big Integers Library #326

wants to merge 16 commits into from

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented Feb 6, 2025

Type of change

  • New Library

Changes

The following changes have been made:

  • Introduces the Big Integers Library with the BigUint type

The BigUint type has the following functions:

  • new()
  • equal_limb_size()
  • number_of_limbs()
  • limbs()
  • get_limb()
  • zero()
  • is_zero()

The following traits are implemented for the BigUint type:

  • Clone
  • From<u8>
  • TryInto<u8>
  • From<u16>
  • TryInto<u16>
  • From<u32>
  • TryInto<u32>
  • From<u64>
  • TryInto<u64>
  • From<U128>
  • TryInto<U128>
  • From<u256>
  • TryInto<u256>
  • From<Bytes>
  • Into<Bytes>
  • Eq
  • Ord
  • OrdEq
  • Add
  • Multiply
  • Subtract

Notes

  • Until this PR is merged, CI link check will error with:
ERROR: 1 dead links found!
  [✖] https://fuellabs.github.io/sway-libs/master/sway_libs/bigint/index.html → Status: 404 

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.
  • I have updated the changelog to reflect the changes on this PR.

@bitzoic bitzoic added Enhancement New feature or request Lib: Math Label used to filter for the library issue labels Feb 6, 2025
@bitzoic bitzoic self-assigned this Feb 6, 2025
@bitzoic bitzoic requested a review from a team as a code owner February 6, 2025 11:46
@bitzoic bitzoic requested review from SwayStar123 and K1-R1 February 11, 2025 13:13
@bitzoic bitzoic requested a review from bajpai244 February 11, 2025 13:17
Copy link
Member

@K1-R1 K1-R1 left a comment

Choose a reason for hiding this comment

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

Overall looks great, a few suggestions then very happy to approve

docs/book/src/bigint/index.md Show resolved Hide resolved

### Type Conversions

The Big Integers Library offers a number of different conversion between mathematical type. These include the following:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The Big Integers Library offers a number of different conversion between mathematical type. These include the following:
The Big Integers Library offers a number of different conversions between mathematical types. These include the following:

@@ -54,6 +54,10 @@ Math Libraries are libraries which provide mathematic functions or number types

The [Signed Integers](./signed_integers/index.md) Library is an interface to implement signed integers.

### [Big Integers](./bigint/index.md)

The [Big Integers](./bigint/index.md) Library is an interface to implement extremely integers.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The [Big Integers](./bigint/index.md) Library is an interface to implement extremely integers.
The [Big Integers](./bigint/index.md) Library is an interface to implement extremely large integers.

self.limbs.len() == other.limbs.len()
}

/// Returns the number of limbs the `BigUint`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Returns the number of limbs the `BigUint`.
/// Returns the number of limbs the `BigUint` has.

docs/book/src/bigint/index.md Show resolved Hide resolved
libs/src/bigint.sw Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Lib: Math Label used to filter for the library issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants