Skip to content

Fix sign of bigdecimal**bigint#341

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:fix_power_by_bigint_sign
Jun 5, 2025
Merged

Fix sign of bigdecimal**bigint#341
tompng merged 1 commit into
ruby:masterfrom
tompng:fix_power_by_bigint_sign

Conversation

@tompng

@tompng tompng commented Jun 4, 2025

Copy link
Copy Markdown
Member

Sign of bigdecimal**bigint was wrong.

(-1)**(2**50)       # => 1
(-1)**(2**50 + 1)   # => -1

(-3.0)**(2**50)     # => Infinity
(-3.0)**(2**50 + 1) # => -Infinity

(-0.5)**(2**50)     # => 0.0
(-0.5)**(2**50 + 1) # => -0.0


BigDecimal(-1)**(2**200)         # => 0.1e1
BigDecimal(-1)**(2**200 + 1)     # => 0.1e1 → -0.1e1

BigDecimal(-3)**(2**200)         # -Infinity → Infinity
BigDecimal(-3)**(2**200 + 1)     # Infinity  → -Infinity

BigDecimal('-0.5')**(2**200)     # => -0.0 → 0.0
BigDecimal('-0.5')**(2**200 + 1) # => 0.0  → -0.0

@tompng tompng merged commit 87c487e into ruby:master Jun 5, 2025
78 checks passed
@tompng tompng deleted the fix_power_by_bigint_sign branch June 5, 2025 13: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