KEMBAR78
BigMath methods common interface: coerce x, validate prec, check nan error by tompng · Pull Request #415 · ruby/bigdecimal · GitHub
Skip to content

Conversation

@tompng
Copy link
Member

@tompng tompng commented Aug 25, 2025

Needs #420 to be merged.

Common interface of BigMath.func(x, prec)

Changes

Numeric arg are coreced into BigDecimal

# These works
BigMath.exp(2, 100)
BigMath.log(2, 100)
# These weren't. Now all works.
BigMath.sqrt(2, 100)
BigMath.sin(2, 100)
BigMath.cos(2, 100)
BigMath.atan(2, 100)

Prec validations are now all same.

# Zero or negative precision for [method_name] (ArgumentError)
BigMath.exp(x, 0)
BigMath.log(x, 0)
BigMath.sin(x, 0)
# This was accepted before. Error now.
BigMath.sqrt(x, 0)

# precision must be an Integer (ArgumentError)
BigMath.log(x, 10.0)
BigMath.exp(x, 10.0) # accepted in bigdecimal 3.2.2, error in current master branch
# These were accepted before. Error now.
BigMath.sqrt(x, 10.0)
BigMath.sin(x, 10.0)
BigMath.cos(x, 10.0)
BigMath.atan(x, 10.0)

@tompng tompng marked this pull request as draft September 3, 2025 08:04
@tompng tompng mentioned this pull request Sep 3, 2025
@tompng tompng force-pushed the bigmath_prec_coerce_nan branch from 9182f75 to 817af8b Compare September 3, 2025 13:50
@tompng tompng force-pushed the bigmath_prec_coerce_nan branch from 817af8b to 5239861 Compare September 12, 2025 14:27
@tompng tompng marked this pull request as ready for review September 12, 2025 14:27
@tompng tompng merged commit 2066c20 into ruby:master Sep 12, 2025
81 checks passed
@tompng tompng deleted the bigmath_prec_coerce_nan branch September 12, 2025 15:09
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