Skip to content

Support fixed-decimal arguments and canonical numeric selection - #31

Merged
waywardmonkeys merged 3 commits into
forest-rs:mainfrom
Georgiy-Tugai:feat/fixed-decimal-args
Sep 18, 2026
Merged

waywardmonkeys merged 3 commits into
forest-rs:mainfrom
Georgiy-Tugai:feat/fixed-decimal-args

Conversation

@Georgiy-Tugai

Copy link
Copy Markdown
Collaborator

Summary

  • Accept owned and borrowed fixed_decimal::Decimal values as message arguments.
  • Preserve decimal precision, sign, and trailing-zero scale for formatting, resolved text, and plural operands.
  • Canonicalize numeric payloads before exact selection:
    • payloads such as 1, 1.0, and 1e0 all select the canonical key 1
    • noncanonical selector keys such as 1.0 and 1e0 do not match
    • 1.2300 selects the canonical key 1.23
    • signed zero selects the canonical key 0
  • Keep textual :string selection scale-sensitive.
  • Apply exact matching to transformed :integer, :offset, and :percent payloads independently of display options.
  • Default unannotated decimal offset results to cardinal plural selection.

Why

Converting decimal arguments through floating point loses precision and scale information. Mathematical equality for exact selector keys also allowed multiple equivalent spellings to match the same value, making selection dependent on source ordering.

This change retains the original decimal representation where formatting and plural semantics require it, while giving numeric exact selection one deterministic MF2-compatible serialization.

Georgiy Tugai added 3 commits September 17, 2026 13:53
Allow owned and borrowed fixed_decimal::Decimal values to enter the facade and runtime argument maps without an f64 conversion. This preserves precision, sign, and trailing-zero scale for formatting, resolved text, and plural operands.
Use one canonical plain-decimal key for numeric exact selection so equivalent source spellings cannot all match the same payload. Keep the comparison allocation-free while preserving decimal scale for formatting, textual selection, and plural operands.
Treat an unannotated resolved decimal like other numeric operands after :offset. This prevents keyword projection from retrying :offset without its required adjustment and lets adjusted decimals select the expected plural category.
@Georgiy-Tugai
Georgiy-Tugai force-pushed the feat/fixed-decimal-args branch from 8f5614a to 2cc0142 Compare September 17, 2026 12:10
@waywardmonkeys
waywardmonkeys merged commit d9861f9 into forest-rs:main Sep 18, 2026
15 checks passed
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.

2 participants