Skip to content

Fix for BigDecimal#/#797

Merged
BanzaiMan merged 1 commit intojruby:masterfrom
tychobrailleur:bigdecimal_div2
Jun 17, 2013
Merged

Fix for BigDecimal#/#797
BanzaiMan merged 1 commit intojruby:masterfrom
tychobrailleur:bigdecimal_div2

Conversation

@tychobrailleur
Copy link
Contributor

This fixes #644 and #648. See this #648 (comment) comment for discussion.

@BanzaiMan
Copy link
Member

@tychobrailleur Could you rebase to the current master and squash these commits into one?

Thanks!

When dividing BigDecimal by a Float, the Float is converted to
Rational “for higher precision,” and then divides the numerator
by the denominator.  However, when doing that division, `div19`
was being used which does a `floor` on the returned float.  This
commit replaces the call to `div19` with `op_div`.
This commit also addresses issues with return type of the result,
which changes from version to version in Ruby.
See https://github.com/rubyspec/rubyspec/pull/220 for tests.

Use java.math.BigDecimal to compute rational and float value.

Make test applicable for 1.9/2.0 only.

Code cleanup.

A bit of housekeeping, adding whitespaces after commas, and around
equals.

Return Float when BigDecimal is divided by Float in 1.9.

Recent versions of 1.9.3 now exhibit the same behaviour as 2.0.
BanzaiMan added a commit that referenced this pull request Jun 17, 2013
@BanzaiMan BanzaiMan merged commit 0447f28 into jruby:master Jun 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in Division of BigDecimal

2 participants