Skip to content

Fix x / y precision when prec limit is huge#412

Merged
tompng merged 1 commit intoruby:masterfrom
tompng:div_preclimit
Aug 22, 2025
Merged

Fix x / y precision when prec limit is huge#412
tompng merged 1 commit intoruby:masterfrom
tompng:div_preclimit

Conversation

@tompng
Copy link
Copy Markdown
Member

@tompng tompng commented Aug 22, 2025

When prec limit set to 10000, BigDecimal(2)/3 was calculated in 10000 digits.
Fixes it to calcualte in 32 digits. Prec limit is just a limit.

BigDecimal(2)/3
# => 0.66666666666666666666666666666667e0

BigDecimal.limit(1000000) # This is just a limit. Not a precision for arithmetic operation.

BigDecimal(2)/3
# => 0.66666666666666666666666666666667e0 (This pull request)
# => 0.6666666666666666666666666666666...66666666666666666666666666666667 (bug)

When prec limit set to 10000, BigDecimal(2)/3 was calculated in 10000 digits.
Fixes it to calcualte in 32 digits. Prec limit is just a limit.
@tompng tompng added the bug label Aug 22, 2025
@tompng tompng merged commit c18bacb into ruby:master Aug 22, 2025
79 checks passed
@tompng tompng deleted the div_preclimit branch August 22, 2025 14:45
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.

1 participant