spiceJ/real-time/src/main/java/at/borkowski/spicej/rt/DelayCalculator.java
public static Result calculate(long nanoseconds, float epsilon) {
      if (epsilon <= 0 || epsilon >= 1)
         throw new IllegalArgumentException("0 < epsilon < 1 not satisfied");

      long max_divider = (int) (1D / epsilon);
      if (nanoseconds < max_divider)
         return new Result(nanoseconds, 1);

      long interval = Math.min(MAX_INTERVAL, nanoseconds / max_divider);
      long correction = nanoseconds / interval;

      return new Result(interval, correction);
   }
public static Result calculate(long nanoseconds, float epsilon) {
      if (epsilon <= 0 || epsilon >= 1)
         throw new IllegalArgumentException("0 < epsilon < 1 not satisfied");

      long max_divider = (int) (1D / epsilon);
      if (nanoseconds < max_divider)
         return new Result(nanoseconds, 1);

      long interval = Math.min(MAX_INTERVAL, nanoseconds / max_divider);
      long correction = nanoseconds / interval;

      return new Result(interval, correction);
   }
Returns a result for the given delay and epsilon (error rate). Epsilon
must be between 0 and 1, exclusively. See {@link DelayCalculator} for
details.

@param nanoseconds
The required delay in nanoseconds
@param epsilon
The permitted error (0 &lt; epsilon &lt; 1)
@return The calculation result