<commit_before>#lang scheme/base

(require (only-in rnrs/base-6
                  div-and-mod div mod
                  div0-and-mod0 div0 mod0
                  [integer? r6rs:integer?]
                  finite? infinite? nan?)
         (only-in rnrs/arithmetic/fixnums-6
                  fixnum?)
         rnrs/conditions-6
         r6rs/private/num-inline
         (for-syntax r6rs/private/inline-rules))

(provide (rename-out [inexact-real? flonum?])
         real->flonum
         flnumerator
         fldenominator
         fllog flsqrt flexpt
         &no-infinities make-no-infinities-violation no-infinities-violation?
         &no-nans make-no-nans-violation no-nans-violation?
         fixnum->flonum)
;; More provided via macros

(define-inliner define-fl inexact-real? "flonum")

(define-fl = fl=? (a b c ...) nocheck)
(define-fl > fl>? (a b c ...) nocheck)
(define-fl < fl<? (a b c ...) nocheck)
(define-fl <= fl<=? (a b c ...) nocheck)
(define-fl >= fl>=? (a b c ...) nocheck)

(define-fl integer? flinteger? (a) nocheck)
(define-fl zero? flzero? (a) nocheck)
(define-fl positive? flpositive? (a) nocheck)
(define-fl negative? flnegative? (a) nocheck)
(define-fl odd? flodd? (a) nocheck)
(define-fl even? fleven? (a) nocheck)
(define-fl finite? flfinite? (a) nocheck)
(define-fl infinite? flinfinite? (a) nocheck)
(define-fl nan? flnan? (a) nocheck)

(define-fl max flmax (a b ...) nocheck)
(define-fl min flmin (a b ...) nocheck)

(define-fl + fl+ (a b ...) nocheck)
(define-fl * fl* (a b ...) nocheck)
(define-fl - fl- [(a) (a b ...)] nocheck)
(define-fl / fl/ [(a) (a b ...)] nocheck)

(define-fl abs flabs (a) nocheck)

(provide fldiv-and-mod
         fldiv0-and-mod0)
(define (fldiv-and-mod a b)
  (unless (inexact-real? a)
    (raise-type-error 'fldiv-and-mod "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'fldiv-and-mod "flonum" b))
  (div-and-mod a b))
(define-fl div fldiv (a b) nocheck)
(define-fl mod flmod (a b) nocheck)
(define (fldiv0-and-mod0 a b)
  (unless (inexact-real? a)
    (raise-type-error 'fldiv0-and-mod0 "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'fldiv0-and-mod0 "flonum" b))
  (div0-and-mod0 a b))
(define-fl div0 fldiv0 (a b) nocheck)
(define-fl mod0 flmod0 (a b) nocheck)

(define (flnumerator c)
  (if (inexact-real? c)
      (if (and (rational? c)
               (not (equal? c -0.0)))
          (numerator c)
          c)
      (raise-type-error 'flnumerator "flonum" c)))

(define (fldenominator c)
  (if (inexact-real? c)
      (if (rational? c)
          (denominator c)
          1.0)
      (raise-type-error 'fldenominator "flonum" c)))

(define-fl floor flfloor (a) nocheck)
(define-fl ceiling flceiling (a) nocheck)
(define-fl truncate fltruncate (a) nocheck)
(define-fl round flround (a) nocheck)

(define-fl exp flexp (a) nocheck)
<commit_msg>r6rs fldiv, etc. need to return nan for zero divisor<commit_after>#lang scheme/base

(require (only-in rnrs/base-6
                  div-and-mod div mod
                  div0-and-mod0 div0 mod0
                  [integer? r6rs:integer?]
                  finite? infinite? nan?)
         (only-in rnrs/arithmetic/fixnums-6
                  fixnum?)
         rnrs/conditions-6
         r6rs/private/num-inline
         (for-syntax r6rs/private/inline-rules))

(provide (rename-out [inexact-real? flonum?])
         real->flonum
         flnumerator
         fldenominator
         fllog flsqrt flexpt
         &no-infinities make-no-infinities-violation no-infinities-violation?
         &no-nans make-no-nans-violation no-nans-violation?
         fixnum->flonum)
;; More provided via macros

(define-inliner define-fl inexact-real? "flonum")

(define-fl = fl=? (a b c ...) nocheck)
(define-fl > fl>? (a b c ...) nocheck)
(define-fl < fl<? (a b c ...) nocheck)
(define-fl <= fl<=? (a b c ...) nocheck)
(define-fl >= fl>=? (a b c ...) nocheck)

(define-fl integer? flinteger? (a) nocheck)
(define-fl zero? flzero? (a) nocheck)
(define-fl positive? flpositive? (a) nocheck)
(define-fl negative? flnegative? (a) nocheck)
(define-fl odd? flodd? (a) nocheck)
(define-fl even? fleven? (a) nocheck)
(define-fl finite? flfinite? (a) nocheck)
(define-fl infinite? flinfinite? (a) nocheck)
(define-fl nan? flnan? (a) nocheck)

(define-fl max flmax (a b ...) nocheck)
(define-fl min flmin (a b ...) nocheck)

(define-fl + fl+ (a b ...) nocheck)
(define-fl * fl* (a b ...) nocheck)
(define-fl - fl- [(a) (a b ...)] nocheck)
(define-fl / fl/ [(a) (a b ...)] nocheck)

(define-fl abs flabs (a) nocheck)

(provide fldiv flmod fldiv-and-mod
         fldiv0 flmod0 fldiv0-and-mod0)
(define (fldiv a b)
  (unless (inexact-real? a)
    (raise-type-error 'fldiv "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'fldiv "flonum" b))
  (if (zero? b)
      +nan.0
      (div a b)))
(define (flmod a b)
  (unless (inexact-real? a)
    (raise-type-error 'flmod "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'flmod "flonum" b))
  (if (zero? b)
      +nan.0
      (mod a b)))
(define (fldiv-and-mod a b)
  (unless (inexact-real? a)
    (raise-type-error 'fldiv-and-mod "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'fldiv-and-mod "flonum" b))
  (if (zero? b)
      (values +nan.0 +nan.0)
      (div-and-mod a b)))
(define (fldiv0-and-mod0 a b)
  (unless (inexact-real? a)
    (raise-type-error 'fldiv0-and-mod0 "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'fldiv0-and-mod0 "flonum" b))
  (if (zero? b)
      (values +nan.0 +nan.0)
      (div0-and-mod0 a b)))
(define (fldiv0 a b)
  (unless (inexact-real? a)
    (raise-type-error 'fldiv0 "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'fldiv0 "flonum" b))
  (if (zero? b)
      +nan.0
      (div0 a b)))
(define (flmod0 a b)
  (unless (inexact-real? a)
    (raise-type-error 'flmod0 "flonum" a))
  (unless (inexact-real? b)
    (raise-type-error 'flmod0 "flonum" b))
  (if (zero? b)
      +nan.0
      (mod0 a b)))

(define (flnumerator c)
  (if (inexact-real? c)
      (if (and (rational? c)
               (not (equal? c -0.0)))
          (numerator c)
          c)
      (raise-type-error 'flnumerator "flonum" c)))

(define (fldenominator c)
  (if (inexact-real? c)
      (if (rational? c)
          (denominator c)
          1.0)
      (raise-type-error 'fldenominator "flonum" c)))

(define-fl floor flfloor (a) nocheck)
(define-fl ceiling flceiling (a) nocheck)
(define-fl truncate fltruncate (a) nocheck)
(define-fl round flround (a) nocheck)

(define-fl exp flexp (a) nocheck)

{'fraction_non_alphanumeric': 0.16602848828304487, 'fraction_numerical': 0.0108745596569153, 'mean_word_length': 2.5741652983032295, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5434014', 'n_tokens_mistral': 2759, 'n_tokens_neox': 2685, 'n_words': 687}