Skip to content

BigMath.exp overflow/underflow check#523

Merged
tompng merged 2 commits intoruby:masterfrom
tompng:exp_overflow_underflow_check
Apr 8, 2026
Merged

BigMath.exp overflow/underflow check#523
tompng merged 2 commits intoruby:masterfrom
tompng:exp_overflow_underflow_check

Conversation

@tompng
Copy link
Copy Markdown
Member

@tompng tompng commented Apr 8, 2026

BigMath.exp(BigDecimal('1e100000000'), 20) was slow.
Skip calculation when x.exponent >= 21 which always result in overflow or underflow.

BigMath.exp(BigDecimal('0.212e20'), 2) #=> 0.16e+9207043016348938747
BigMath.exp(BigDecimal('0.213e20'), 2) #=> Infinity

BigMath.exp(BigDecimal('-0.212e20'), 2) #=> 0.63e-9207043016348938746
BigMath.exp(BigDecimal('-0.213e20'), 2) #=> 0.0

tompng added 2 commits April 8, 2026 22:53
`BigMath.exp(BigDecimal('1e100000000'), 20)` was slow.
Skip calculation when x.exponent >= 21 which always result in overflow or underflow.
@tompng tompng force-pushed the exp_overflow_underflow_check branch from ddf7d76 to b736528 Compare April 8, 2026 13:53
@tompng tompng merged commit 50b80b1 into ruby:master Apr 8, 2026
84 checks passed
@tompng tompng deleted the exp_overflow_underflow_check branch April 8, 2026 16:51
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.

1 participant