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

feat: add pow2 and pow10 utilizing const arrays #323

Open
1 of 2 tasks
milancermak opened this issue Aug 6, 2024 · 4 comments
Open
1 of 2 tasks

feat: add pow2 and pow10 utilizing const arrays #323

milancermak opened this issue Aug 6, 2024 · 4 comments
Labels
enhancement Enhancement of the code, not introducing new features.

Comments

@milancermak
Copy link
Contributor

Feature Request

Describe the Feature Request

Cairo 2.7.0 brought back the use of dw in const array. In Cairo0, it was used by a lot of projects to have the most efficient implementation of power of 2 and power of 10 since instead of looping it's just a lookup table.

pow2 and pow10 are the most commonly used powers - for example, the former is used in Alexandria as well for bitshifting, the latter is often used for defi applications as we deal with powers of ERC20.decimals there.

Describe Preferred Solution

Something like:

pub fn pow10(n: usize) -> u128 {
    *(P10.span()[n])
}

And similarly for pow2.

Related Code

Additional Context

If the feature request is approved, would you be willing to submit a PR?
(Help can be provided if you need assistance submitting a PR)

  • Yes
  • No
@milancermak milancermak added the enhancement Enhancement of the code, not introducing new features. label Aug 6, 2024
@PavitraAgarwal21
Copy link

can i take this up

Copy link

onlydustapp bot commented Aug 15, 2024

Hey @PavitraAgarwal21!
Thanks for showing interest.
We've created an application for you to contribute to Alexandria.
Go check it out on OnlyDust!

@oluwa-peski
Copy link

oluwa-peski commented Aug 26, 2024

Is this issue still open? I'd like to complete it, but can't find a way to apply for it on onlydust
@milancermak

Copy link

onlydustapp bot commented Aug 26, 2024

Hey @oluwa-peski!
Thanks for showing interest.
We've created an application for you to contribute to Alexandria.
Go check it out on OnlyDust!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of the code, not introducing new features.
Projects
None yet
Development

No branches or pull requests

3 participants