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

Use BigDecimal#precision instead of BigDecimal#precs when available #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

korbin
Copy link
Contributor

@korbin korbin commented Mar 13, 2024

Ruby 3.3.1 moves this method into #precision and #n_significant_digits - precs gives wildly different results between versions/platforms, this is an important fix IMO.

@korbin korbin requested a review from v2kovac March 13, 2024 21:34
@@ -21,7 +21,7 @@ def to_message(object, field)
field.subtype.msgclass.new(
numerator: rational.numerator,
denominator: rational.denominator,
precision: object.precs[0], # This is the current precision of the decimal
precision: object.try(:precision) || object.precs[0], # This is the current precision of the decimal
Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't returning the same value for a basic example like

a = BigDecimal("0.123")
a.precision => 3
a.precs[0] => 9

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

Successfully merging this pull request may close these issues.

2 participants