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

math: more type tests #6713

Merged
merged 3 commits into from
May 13, 2024
Merged

Conversation

a5-pickle
Copy link
Contributor

Running the following command has been helpful determining which types to use for various math operations:

cargo test-sbf -- --nocapture --test-threads=1

In considering how to perform math in our programs (whether to create methods to replicate performing floating-point arithmetic or to use floats directly), we needed to benchmark some arithmetic with u128 vs f64.

This PR adds multiplication and division for each of these types.

@mergify mergify bot added the community Community contribution label May 9, 2024
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Looks really good, thanks for the contribution!

let (mut banks_client, payer, recent_blockhash) = pc.start().await;

let mut transaction = Transaction::new_with_payer(
&[instruction::u128_divide(u128::MAX, u128::MAX / 69)],
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

let (mut banks_client, payer, recent_blockhash) = pc.start().await;

let mut transaction = Transaction::new_with_payer(
&[instruction::f64_divide(f64::powf(2., 42.), 420420.6969)],
Copy link
Contributor

Choose a reason for hiding this comment

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

nice nice

@joncinque joncinque merged commit d1c03cc into solana-labs:master May 13, 2024
11 checks passed
@a5-pickle a5-pickle deleted the math/more-types branch May 14, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants