<commit_before>(in-package :sys.int)

(defvar *print-array* t)
(defvar *print-base* 10)
(defvar *print-case* :upcase)
(defvar *print-circle* nil)
(defvar *print-escape* t)
(defvar *print-gensym* t)
(defvar *print-length* nil)
(defvar *print-level* nil)
(defvar *print-lines* nil)
(defvar *print-miser-width* nil)
(defvar *print-pprint-dispatch* nil)
(defvar *print-pretty* nil)
(defvar *print-radix* nil)
(defvar *print-readably* nil)
(defvar *print-right-margin* nil)

(defvar *print-safe* nil)
(defvar *print-space-char-ansi* nil)
(defvar *print-bignums-safely* nil)

(defun write-unsigned-integer-inner (x base stream)
  (unless (= x 0)
    (multiple-value-bind (quot rem)
        (truncate x base)
      (write-unsigned-integer quot base stream)
      (write-char (schar "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rem)
                  stream))))

(defun write-unsigned-integer-outer (x base base-divisor stream)
  (unless (= x 0)
    (multiple-value-bind (quot rem)
        (truncate x base-divisor)
      (write-unsigned-integer-outer quot base base-divisor stream)
      (write-unsigned-integer-inner rem base stream))))

(defun write-unsigned-integer (x base stream)
  (cond ((fixnump x)
         (write-unsigned-integer-inner x base stream))
        (t
         (write-unsigned-integer-outer x base
                                       (expt base (floor (log most-positive-fixnum base)))
                                       stream))))

(defun write-integer (x &optional (base 10) stream)
  (cond ((and *print-bignums-safely*
              (bignump x)
              (>= (%array-like-length x) 2))
         ;; Very large bignum.
         (write-string "#<Bignum" stream)
         (dotimes (i (%array-like-length x))
           (format stream " ~16,'0X"
                   (%array-like-ref-unsigned-byte-64 x (- (%array-like-length x) i 1))))
         (write-char #\> stream))
        ((= x 0)
         (write-char #\0 stream))
        ((< x 0)
         (write-char #\- stream)
         (write-unsigned-integer (- 0 x) base stream))
        (t (write-unsigned-integer x base stream))))

(defun write-float (float stream &optional (trailing-digits 6))
  (when (float-nan-p float)
    (print-unreadable-object (float stream :type t)
      (format stream "~A NaN" (if (float-trapping-nan-p float) "signalling" "quiet")))
    (return-from write-float))
  (when (float-infinity-p float)
    (if (minusp float)
        (format stream "#.~S" 'single-float-negative-infinity)
        (format stream "#.~S" 'single-float-positive-infinity))
    (return-from write-float))
  (when (< float 0.0)
    (write-char #\- stream)<commit_msg>Fix the integer printing code.<commit_after>(in-package :sys.int)

(defvar *print-array* t)
(defvar *print-base* 10)
(defvar *print-case* :upcase)
(defvar *print-circle* nil)
(defvar *print-escape* t)
(defvar *print-gensym* t)
(defvar *print-length* nil)
(defvar *print-level* nil)
(defvar *print-lines* nil)
(defvar *print-miser-width* nil)
(defvar *print-pprint-dispatch* nil)
(defvar *print-pretty* nil)
(defvar *print-radix* nil)
(defvar *print-readably* nil)
(defvar *print-right-margin* nil)

(defvar *print-safe* nil)
(defvar *print-space-char-ansi* nil)
(defvar *print-bignums-safely* nil)

(defun write-unsigned-integer-inner (x base n-digits stream)
  (unless (zerop n-digits)
    (multiple-value-bind (quot rem)
        (truncate x base)
      (write-unsigned-integer-inner quot base (1- n-digits) stream)
      (write-char (schar "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rem)
                  stream))))

(defun write-unsigned-integer-outer (x base base-divisor base-digits stream)
  (unless (zerop x)
    (multiple-value-bind (quot rem)
        (truncate x base-divisor)
      (write-unsigned-integer-outer quot base base-divisor base-digits stream)
      (if (zerop quot)
          (write-unsigned-integer-simple rem base stream)
          (write-unsigned-integer-inner rem base base-digits stream)))))

(defun write-unsigned-integer-simple (x base stream)
  (unless (zerop x)
    (multiple-value-bind (quot rem)
        (truncate x base)
      (write-unsigned-integer-simple quot base stream)
      (write-char (schar "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rem)
                  stream))))

(defun write-unsigned-integer (x base stream)
  (cond ((fixnump x)
         (write-unsigned-integer-simple x base stream))
        (t
         (let ((digits (floor (log most-positive-fixnum base))))
           (write-unsigned-integer-outer x base
                                         (expt base digits)
                                         digits
                                         stream)))))

(defun write-integer (x &optional (base 10) stream)
  (cond ((and *print-bignums-safely*
              (bignump x)
              (>= (%array-like-length x) 2))
         ;; Very large bignum.
         (write-string "#<Bignum" stream)
         (dotimes (i (%array-like-length x))
           (format stream " ~16,'0X"
                   (%array-like-ref-unsigned-byte-64 x (- (%array-like-length x) i 1))))
         (write-char #\> stream))
        ((= x 0)
         (write-char #\0 stream))
        ((< x 0)
         (write-char #\- stream)
         (write-unsigned-integer (- 0 x) base stream))
        (t (write-unsigned-integer x base stream))))

(defun write-float (float stream &optional (trailing-digits 6))
  (when (float-nan-p float)
    (print-unreadable-object (float stream :type t)
      (format stream "~A NaN" (if (float-trapping-nan-p float) "signalling" "quiet")))
    (return-from write-float))
  (when (float-infinity-p float)
    (if (minusp float)
        (format stream "#.~S" 'single-float-negative-infinity)
        (format stream "#.~S" 'single-float-positive-infinity))
    (return-from write-float))
  (when (< float 0.0)
    (write-char #\- stream)
{'fraction_non_alphanumeric': 0.14690721649484537, 'fraction_numerical': 0.011855670103092783, 'mean_word_length': 2.530018192844148, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7088255', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1920, 'n_words': 499}