clamp method

Decimal clamp(
  1. Decimal lowerLimit,
  2. Decimal upperLimit
)

Clamps this to be in the range lowerLimit-upperLimit. The comparison is done using compareTo and therefore takes -0.0 into account.

Implementation

Decimal clamp(Decimal lowerLimit, Decimal upperLimit) =>
    Decimal._fromRational(
        _rational.clamp(lowerLimit._rational, upperLimit._rational));