Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

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
@a5-pickle a5-pickle deleted the math/more-types branch May 14, 2024 13:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants