Skip to content

Conversation

@olbrich
Copy link
Owner

@olbrich olbrich commented Dec 30, 2025

Add opt-in BigDecimal parsing for numeric literals in unit strings.

  • Introduces RubyUnits::MissingDependencyError.
  • Adds Configuration#use_bigdecimal (boolean, default: false). Enabling requires require 'bigdecimal'.
  • Adds Unit.parse_number to centralize numeric coercion: returns BigDecimal when use_bigdecimal is enabled, otherwise Float.
  • Updates parsing, conversion, and normalization code to use parse_number and normalize_to_i, and adds Unit#to_d so scalars may be BigDecimal and still normalize to Integer when mathematically integral.
  • Adds specs in bigdecimal_parsing_spec.rb to validate parsing and normalization behavior when BigDecimal is enabled.

Misc: small RuboCop config and formatting changes.
Notes:

Important

BigDecimal parsing is opt-in; callers must require 'bigdecimal' before enabling.

Related to #372

@olbrich olbrich self-assigned this Dec 30, 2025
@olbrich olbrich added the Minor add functionality in a backwards-compatible manner label Dec 30, 2025
@olbrich olbrich marked this pull request as ready for review December 30, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Minor add functionality in a backwards-compatible manner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants