Skip to content

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

Open
korbin wants to merge 1 commit intomasterfrom
bigdecimal-fix
Open

Use BigDecimal#precision instead of BigDecimal#precs when available#54
korbin wants to merge 1 commit intomasterfrom
bigdecimal-fix

Conversation

@korbin
Copy link
Copy Markdown
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
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
Copy Markdown
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