<commit_before>module Numeric

  def abs
    Erlang.abs(self)
  end

  def abs2
    self * self
  end

  def truncate
    Erlang.trunc(self)
  end

  def round
    Erlang.round(self)
  end

  def round(precision) when precision > 0
    _round_with_precision(precision)
  end

  def round(precision) when precision < 0
    _round_with_precision(precision).truncate
  end

  def round(_)
    round
  end

  def floor
    case self
    match x when x < 0 then (x - 1).truncate
    match x then x.truncate
    end
  end

  def ceil
    case self
    match x when x < 0 then x.truncate
    match x then (x + 1).truncate
    end
  end

  def integer?
    Erlang.is_integer self
  end

  def zero?
    self == 0
  end

  def nonzero?
    !zero?
  end

  ['+, '-, '*, '/].each do (op)
    define_erlang_method __FILE__, __LINE__, op, 1, [
      {
        'clause, __LINE__, [{'var, __LINE__, 'other}], [], [
          { 'op, __LINE__, op, {'var, __LINE__, 'self}, {'var, __LINE__, 'other} }
        ]
      }
    ]
  end

  private

    def _round_with_precision(precision)
      magnitude = Math.pow(10, precision)
      (self * magnitude).round / magnitude
    end

end<commit_msg>Added comments<commit_after>module Numeric

  % Returns the absolute value of self.
  def abs
    Erlang.abs(self)
  end

  % Returns square of self.
  def abs2
    self * self
  end

  def truncate
    Erlang.trunc(self)
  end

  def round
    Erlang.round(self)
  end

  def round(precision) when precision > 0
    _round_with_precision(precision)
  end

  def round(precision) when precision < 0
    _round_with_precision(precision).truncate
  end

  def round(_)
    round
  end

  % Returns the largest Integer less than or equal to self.
  def floor
    case self
    match x when x < 0 then (x - 1).truncate
    match x then x.truncate
    end
  end

  % Returns the smallest Integer greater than or equal to self.
  def ceil
    case self
    match x when x < 0 then x.truncate
    match x then (x + 1).truncate
    end
  end

  % Returns true if integer
  def integer?
    Erlang.is_integer self
  end

  % Returns true if zero
  def zero?
    self == 0
  end

  % Returns true if not zero
  def nonzero?
    !zero?
  end

  ['+, '-, '*, '/].each do (op)
    define_erlang_method __FILE__, __LINE__, op, 1, [
      {
        'clause, __LINE__, [{'var, __LINE__, 'other}], [], [
          { 'op, __LINE__, op, {'var, __LINE__, 'self}, {'var, __LINE__, 'other} }
        ]
      }
    ]
  end

  private

    def _round_with_precision(precision)
      magnitude = Math.pow(10, precision)
      (self * magnitude).round / magnitude
    end

end
{'fraction_non_alphanumeric': 0.09409523809523809, 'fraction_numerical': 0.008380952380952381, 'mean_word_length': 2.2661691542288556, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '3774442', 'n_tokens_mistral': 956, 'n_tokens_neox': 883, 'n_words': 285}