Class Calculation

java.lang.Object
de.redstoneworld.redutilities.math.Calculation

public class Calculation extends Object
  • Constructor Details

    • Calculation

      public Calculation()
  • Method Details

    • getMillisFromServerTicks

      public static long getMillisFromServerTicks(long serverTicks)
    • getServerTicksFromMillis

      public static long getServerTicksFromMillis(long millis)
    • roundToX

      public static double roundToX(double input, double step)
      This method rounds up the input to the desired accuracy. The accuracy value specifies the step sizes between which rounding takes place.
      • The value is always rounded to the nearest multiple of step.
      • Ties (values exactly halfway between two multiples) are always rounded up, following the behavior of Math.round(double).
      • Smaller values of step result in finer rounding granularity.
      Examples:
      • step = 1.0 => 0.0; 1.0
      • step = 0.5 => 0.0; 0.5; 1.0
      • step = 0.25 => 0.0; 0.25; 0.5; 0.75; 1.0
      • step = 0.1 => 0.0; 0.1; ... 0.9; 1.0
      • step = 0.05 => 0.0; 0.05; ... 0.95; 1.0
      Parameters:
      input - (double) the target value for the rounding
      step - (double) rounding accuracy
      Returns:
      (double) the rounded value
    • isBetween

      public static boolean isBetween(double value, double limitA, double limitB, boolean inclusiveLimitValues)
      This method checks whether a specific value is within a range of values. Two limit values are used as interval limits, whose order (MIN, MAX) is irrelevant. The limit is included ("Closed Interval"), if 'inclusiveLimitValues' is 'true'. Otherwise, the limit is exclusive ("Open Interval").
      Parameters:
      value - (Double) the target value for the check
      limitA - (Double) the first interval limit
      limitB - (Double) the second interval limit
      inclusiveLimitValues - (Boolean) 'true', if the interval limits are included in the range
      Returns:
      (Boolean) 'true', if the target values is a part of the specified interval