<commit_before>package org.timepedia.chronoscope.client.util;

/**
 * Conglomeration of common math functions.
 * 
 * @author <NAME> &lt;<EMAIL>&gt;
 */
public final class MathUtil {

  /**
   * Returns true only if the specified value is in the range [p1, p2]. Note
   * that this method does not check if [p1, p2] is a valid range (e.g. if p1 is
   * greater than p2). Return value is undefined if any of the inputs are
   * <tt>Double.NaN</tt>, <tt>Double.POSITIVE_INFINITY</tt>, or
   * <tt>Double.NEGATIVE_INFINITY</tt>.
   */
  public static boolean isBounded(double value, double p1, double p2) {
    return value >= p1 && value <= p2;
  }

  /**
   * Returns true only if the specified value is in the range [p1, p2]. Note
   * that this method does not check if [p1, p2] is a valid range (e.g. if p1 is
   * greater than p2).
   */
  public static boolean isBounded(int value, int p1, int p2) {
    return value >= p1 && value <= p2;
  }

  /**
   * Calculates log base 2 of the specified value.
   */
  public static double log2(double value) {
    return Math.log(value) / Math.log(2);
  }
  
  public static int mod(int x, int y) {
    return (int)mod((double)x,(double)y);
  }
  
  /**
   * Performs 'x modulo y' (not to be confused with the remainder operator '%', which
   * behaves differently when x is negative).
   */
  public static double mod(double x, double y) {
    if (x >= 0) {
      return x % y;
    }
    else {
      double tmp = -x % y; // make x positive before calc'ing remainder
      return (tmp == 0) ? tmp : (y - tmp);
    }
  }
}<commit_msg>MathUtil.mod(int,int) now provides its own implmentation rather than casting the args to double and delgating to mod(double,double) -- latter implmentation affected performance noticibly -- This line, and those below, will be ignored--<commit_after>package org.timepedia.chronoscope.client.util;

/**
 * Conglomeration of common math functions.
 * 
 * @author <NAME> &lt;<EMAIL>&gt;
 */
public final class MathUtil {

  /**
   * Returns true only if the specified value is in the range [p1, p2]. Note
   * that this method does not check if [p1, p2] is a valid range (e.g. if p1 is
   * greater than p2). Return value is undefined if any of the inputs are
   * <tt>Double.NaN</tt>, <tt>Double.POSITIVE_INFINITY</tt>, or
   * <tt>Double.NEGATIVE_INFINITY</tt>.
   */
  public static boolean isBounded(double value, double p1, double p2) {
    return value >= p1 && value <= p2;
  }

  /**
   * Returns true only if the specified value is in the range [p1, p2]. Note
   * that this method does not check if [p1, p2] is a valid range (e.g. if p1 is
   * greater than p2).
   */
  public static boolean isBounded(int value, int p1, int p2) {
    return value >= p1 && value <= p2;
  }

  /**
   * Calculates log base 2 of the specified value.
   */
  public static double log2(double value) {
    return Math.log(value) / Math.log(2);
  }
  
  public static int mod(int x, int y) {
    if (x >= 0) {
      return x % y;
    }
    else {
      int tmp = -x % y; // make x positive before calc'ing remainder
      return (tmp == 0) ? tmp : (y - tmp);
    }
  }
  
  /**
   * Performs 'x modulo y' (not to be confused with the remainder operator '%', which
   * behaves differently when x is negative).
   */
  public static double mod(double x, double y) {
    if (x >= 0) {
      return x % y;
    }
    else {
      double tmp = -x % y; // make x positive before calc'ing remainder
      return (tmp == 0) ? tmp : (y - tmp);
    }
  }
}
{'fraction_non_alphanumeric': 0.12247223013386499, 'fraction_numerical': 0.01481059527200228, 'mean_word_length': 2.6243550051599587, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '985139', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1157, 'n_words': 446}