Skip to content

Add Clamp method for Decimal type#421

Open
walle250ai wants to merge 2 commits intoshopspring:masterfrom
walle250ai:master
Open

Add Clamp method for Decimal type#421
walle250ai wants to merge 2 commits intoshopspring:masterfrom
walle250ai:master

Conversation

@walle250ai
Copy link
Copy Markdown

Summary

  • Add Clamp(min, max Decimal) Decimal method to the Decimal type
  • Returns min if the value is below range, max if above, otherwise the value itself
  • Panics with a descriptive message when min > max
  • Add comprehensive unit tests covering boundary values, in-range, out-of-range, and panic cases

Clamp returns min if d < min, max if d > max, and d otherwise.
Panics with a descriptive message if min > max.
Supplement unit tests covering positive/negative midpoints, non-midpoint
values, places=0, multi-decimal, negative places, and high-precision cases.
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