Class Decimals

java.lang.Object
civitas.celestis.math.decimal.Decimals

public final class Decimals extends Object
Contains utilities related to BigDecimals.
  • Field Details

    • RUNTIME_PRECISION

      public static final int RUNTIME_PRECISION
      See Also:
    • RUNTIME_ROUNDING_MODE

      public static final RoundingMode RUNTIME_ROUNDING_MODE
    • RUNTIME_CONTEXT

      public static final MathContext RUNTIME_CONTEXT
  • Method Details

    • clamp

      @Nonnull public static BigDecimal clamp(@Nonnull BigDecimal val, @Nonnull BigDecimal min, @Nonnull BigDecimal max)
      Clamps the provided value val to respect the range of [min, max].
      Parameters:
      val - The value of which to clamp
      min - The minimum allowed value (inclusive)
      max - The maximum allowed value (inclusive)
      Returns:
      The clamped value