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

Factor powers of ten before dividing BigDecimals #7218

Merged
merged 1 commit into from
Dec 27, 2018

Conversation

Sija
Copy link
Contributor

@Sija Sija commented Dec 27, 2018

Fixes #7122

@Sija Sija changed the title Factor powers of then before dividing BigDecimal Factor powers of ten before dividing BigDecimals Dec 27, 2018
Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

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

Thank you @Sija 👍

@RX14 RX14 merged commit da9d865 into crystal-lang:master Dec 27, 2018
@RX14 RX14 added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric labels Dec 27, 2018
@RX14 RX14 added this to the 0.27.1 milestone Dec 27, 2018
@@ -148,6 +148,7 @@ describe BigDecimal do
BigDecimal.new(-1) / BigDecimal.new(0)
end
BigDecimal.new(1).should eq(BigDecimal.new(1) / BigDecimal.new(1))
BigDecimal.new(10).should eq(BigDecimal.new(100, 1) / BigDecimal.new(100000000, 8))
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but all of these assertions are written backwards: what one expects to get should be at the right-hand side.

@@ -204,6 +204,7 @@ struct BigDecimal < Number
# ```
def div(other : BigDecimal, max_div_iterations = DEFAULT_MAX_DIV_ITERATIONS) : BigDecimal
check_division_by_zero other
other.factor_powers_of_ten
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since calling factor_powers_of_ten is changing internal object state, should we dup the other before calling it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants