def truncate(numeral, round_up=nil)
      check_base numeral
      unless simplifying? # TODO: could simplify this just skiping on free?
        n = precision(numeral)
        if n == 0
          return numeral if numeral.repeating? # or rails inexact...
          n = numeral.digits.size
        end
        unless n >= numeral.digits.size && numeral.approximate?
          if n < numeral.digits.size - 1
            rest_digits = numeral.digits[n+1..-1]
          else
            rest_digits = []
          end
          if numeral.repeating? && numeral.repeat < numeral.digits.size && n >= numeral.repeat
            rest_digits += numeral.digits[numeral.repeat..-1]
          end
          digits = numeral.digits[0, n]
          if digits.size < n
            digits += (digits.size...n).map{|i| numeral.digit_value_at(i)}
          end
          if numeral.base % 2 == 0
            tie_digit = numeral.base / 2
            max_lo = tie_digit - 1
          else
            max_lo = numeral.base / 2
          end
          next_digit = numeral.digit_value_at(n)
          if next_digit == 0
            unless round_up.nil? && rest_digits.all?{|d| d == 0}
              round_up = :lo
            end
          elsif next_digit <= max_lo # next_digit < tie_digit
            round_up = :lo
          elsif next_digit == tie_digit
            if round_up || rest_digits.any?{|d| d != 0}
              round_up = :hi
            else
              round_up = :tie
            end
          else # next_digit > tie_digit
            round_up = :hi
          end
          numeral = Numeral[
                      digits, point: numeral.point, sign: numeral.sign,
                      base: numeral.base,
                      normalize: :approximate
                    ]
        end
      end
      [numeral, round_up]
    end
def truncate(numeral, round_up=nil)
      check_base numeral
      unless simplifying? # TODO: could simplify this just skiping on free?
        n = precision(numeral)
        if n == 0
          return numeral if numeral.repeating? # or rails inexact...
          n = numeral.digits.size
        end
        unless n >= numeral.digits.size && numeral.approximate?
          if n < numeral.digits.size - 1
            rest_digits = numeral.digits[n+1..-1]
          else
            rest_digits = []
          end
          if numeral.repeating? && numeral.repeat < numeral.digits.size && n >= numeral.repeat
            rest_digits += numeral.digits[numeral.repeat..-1]
          end
          digits = numeral.digits[0, n]
          if digits.size < n
            digits += (digits.size...n).map{|i| numeral.digit_value_at(i)}
          end
          if numeral.base % 2 == 0
            tie_digit = numeral.base / 2
            max_lo = tie_digit - 1
          else
            max_lo = numeral.base / 2
          end
          next_digit = numeral.digit_value_at(n)
          if next_digit == 0
            unless round_up.nil? && rest_digits.all?{|d| d == 0}
              round_up = :lo
            end
          elsif next_digit <= max_lo # next_digit < tie_digit
            round_up = :lo
          elsif next_digit == tie_digit
            if round_up || rest_digits.any?{|d| d != 0}
              round_up = :hi
            else
              round_up = :tie
            end
          else # next_digit > tie_digit
            round_up = :hi
          end
          numeral = Numeral[
                      digits, point: numeral.point, sign: numeral.sign,
                      base: numeral.base,
                      normalize: :approximate
                    ]
        end
      end
      [numeral, round_up]
    end
Truncate a numeral and return also a round_up value with information about
 the digits beyond the truncation point that can be used to round the truncated
 numeral. If the numeral has already been truncated, the round_up result of
 that prior truncation should be passed as the second argument.