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

Implement Multiplication and Division of Quantities #15

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

volfco
Copy link

@volfco volfco commented Mar 5, 2024

As the title says. I implemented Multiplication and Division

Copy link
Owner

@ThomasK33 ThomasK33 left a comment

Choose a reason for hiding this comment

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

Sorry, I somehow missed this PR. Very nice, thank you.

@ThomasK33 ThomasK33 merged commit acb8cb0 into ThomasK33:main Jun 12, 2024
@ThomasK33
Copy link
Owner

I'll probably also add some more syntactic sugar so that one would be able to do:

        let exp_result = ParsedQuantity {
            value: Decimal::from_f32(2.0).unwrap(),
            scale: Scale::Kilo,
            format: Format::BinarySI,
        };

        let q1 = ParsedQuantity {
            value: Decimal::from_f32(4.0).unwrap(),
            scale: Scale::Kilo,
            format: Format::BinarySI,
        };

        let q2: Decimal = 2.into();

        let result = q1 / q2;

        assert_eq!(result, exp_result);

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

Successfully merging this pull request may close these issues.

2 participants