
(/VERSIONCHECK 2) 

(DEFUN |NUMFMT;replaceD| (|c| $)
  (COND
   ((SPADCALL |c| (SPADCALL "D" (QREFELT $ 8)) (QREFELT $ 10))
    (SPADCALL "E" (QREFELT $ 8)))
   ('T |c|))) 

(DEFUN |NUMFMT;replaced| (|c| $)
  (COND
   ((SPADCALL |c| (SPADCALL "d" (QREFELT $ 8)) (QREFELT $ 10))
    (SPADCALL "E" (QREFELT $ 8)))
   ('T |c|))) 

(DEFUN |NUMFMT;contract| (|s| $)
  (PROG (|ls|)
    (RETURN
     (SEQ
      (LETT |s|
            (SPADCALL (CONS (|function| |NUMFMT;replaceD|) $) |s|
                      (QREFELT $ 12))
            . #1=(|NUMFMT;contract|))
      (LETT |s|
            (SPADCALL (CONS (|function| |NUMFMT;replaced|) $) |s|
                      (QREFELT $ 12))
            . #1#)
      (LETT |ls| (SPADCALL |s| (SPADCALL " " (QREFELT $ 8)) (QREFELT $ 14))
            . #1#)
      (EXIT (LETT |s| (SPADCALL |ls| (QREFELT $ 15)) . #1#)))))) 

(DEFUN |NUMFMT;check| (|s| $)
  (COND
   ((NUMBERP (READ-FROM-STRING |s|))
    (COND
     ((SPADCALL (CONS #'|NUMFMT;check!0| $) |s| (QREFELT $ 17))
      (COND ((SPADCALL (CONS #'|NUMFMT;check!1| $) |s| (QREFELT $ 17)) 'T)
            (#1='T 'NIL)))
     (#1# 'T)))
   (#1# 'NIL))) 

(DEFUN |NUMFMT;check!1| (|c1| $)
  (SPADCALL |c1| (SPADCALL "." (QREFELT $ 8)) (QREFELT $ 10))) 

(DEFUN |NUMFMT;check!0| (|c1| $)
  (SPADCALL |c1| (SPADCALL "E" (QREFELT $ 8)) (QREFELT $ 10))) 

(DEFUN |NUMFMT;ScanFloatIgnoreSpaces;SF;5| (|s| $)
  (PROG (|f| |sCheck| |sex|)
    (RETURN
     (SEQ
      (LETT |s| (|NUMFMT;contract| |s| $)
            . #1=(|NUMFMT;ScanFloatIgnoreSpaces;SF;5|))
      (COND
       ((NULL (|NUMFMT;check| |s| $)) (EXIT (|error| "Non-numeric value"))))
      (LETT |sex| (|interpret| (|packageTran| (|ncParseFromString| |s|)))
            . #1#)
      (LETT |sCheck| (SPADCALL (SPADCALL |sex| (QREFELT $ 23)) (QREFELT $ 23))
            . #1#)
      (EXIT
       (COND
        ((|BooleanEquality| (SPADCALL |sCheck| (QREFELT $ 22) (QREFELT $ 24))
                            'T)
         (LETT |f| (SPADCALL (SPADCALL |sex| (QREFELT $ 25)) (QREFELT $ 25))
               . #1#))
        ((|BooleanEquality|
          (SPADCALL (SPADCALL |sex| (QREFELT $ 25)) (QREFELT $ 26)) 'T)
         (SEQ (LETT |f| (SPADCALL |sex| (QREFELT $ 25)) . #1#)
              (EXIT (SPADCALL |f| (QREFELT $ 29)))))
        ('T (|error| "Non-numeric value")))))))) 

(DEFUN |NUMFMT;ScanFloatIgnoreSpacesIfCan;SU;6| (|s| $)
  (PROG (|f| |sCheck| |sex|)
    (RETURN
     (SEQ
      (LETT |s| (|NUMFMT;contract| |s| $)
            . #1=(|NUMFMT;ScanFloatIgnoreSpacesIfCan;SU;6|))
      (COND ((NULL (|NUMFMT;check| |s| $)) (EXIT (CONS 1 "failed"))))
      (LETT |sex| (|interpret| (|packageTran| (|ncParseFromString| |s|)))
            . #1#)
      (LETT |sCheck| (SPADCALL (SPADCALL |sex| (QREFELT $ 23)) (QREFELT $ 23))
            . #1#)
      (EXIT
       (COND
        ((|BooleanEquality| (SPADCALL |sCheck| (QREFELT $ 22) (QREFELT $ 24))
                            'T)
         (LETT |f|
               (CONS 0
                     (SPADCALL (SPADCALL |sex| (QREFELT $ 25)) (QREFELT $ 25)))
               . #1#))
        ((|BooleanEquality|
          (SPADCALL (SPADCALL |sex| (QREFELT $ 25)) (QREFELT $ 26)) 'T)
         (SEQ (LETT |f| (SPADCALL |sex| (QREFELT $ 25)) . #1#)
              (EXIT (CONS 0 (SPADCALL |f| (QREFELT $ 29))))))
        ('T (CONS 1 "failed")))))))) 

(PUT '|NUMFMT;FormatArabic;PiS;7| '|SPADreplace| 'STRINGIMAGE) 

(DEFUN |NUMFMT;FormatArabic;PiS;7| (|n| $) (STRINGIMAGE |n|)) 

(PUT '|NUMFMT;ScanArabic;SPi;8| '|SPADreplace| 'PARSE-INTEGER) 

(DEFUN |NUMFMT;ScanArabic;SPi;8| (|s| $) (PARSE-INTEGER |s|)) 

(DEFUN |NUMFMT;FormatRoman;PiS;9| (|pn| $)
  (PROG (|s| |mm| |j| #1=#:G1880 |m0| |n| |d| |i| #2=#:G1867)
    (RETURN
     (SEQ (LETT |n| |pn| . #3=(|NUMFMT;FormatRoman;PiS;9|))
          (LETT |d| (+ (REMAINDER2 |n| 10) (QREFELT $ 39)) . #3#)
          (LETT |n| (QUOTIENT2 |n| 10) . #3#)
          (LETT |s| (QAREF1 (QREFELT $ 36) |d|) . #3#)
          (EXIT
           (COND ((ZEROP |n|) |s|)
                 (#4='T
                  (SEQ (LETT |d| (+ (REMAINDER2 |n| 10) (QREFELT $ 40)) . #3#)
                       (LETT |n| (QUOTIENT2 |n| 10) . #3#)
                       (LETT |s| (STRCONC (QAREF1 (QREFELT $ 37) |d|) |s|)
                             . #3#)
                       (EXIT
                        (COND ((ZEROP |n|) |s|)
                              (#4#
                               (SEQ
                                (LETT |d|
                                      (+ (REMAINDER2 |n| 10) (QREFELT $ 41))
                                      . #3#)
                                (LETT |n| (QUOTIENT2 |n| 10) . #3#)
                                (LETT |s|
                                      (STRCONC (QAREF1 (QREFELT $ 38) |d|) |s|)
                                      . #3#)
                                (EXIT
                                 (COND ((ZEROP |n|) |s|)
                                       (#4#
                                        (SEQ
                                         (LETT |d| (REMAINDER2 |n| 10) . #3#)
                                         (LETT |n| (QUOTIENT2 |n| 10) . #3#)
                                         (LETT |s|
                                               (STRCONC
                                                (MAKE-FULL-CVEC
                                                 (PROG1 (LETT #2# |d| . #3#)
                                                   (|check-subtype| (>= #2# 0)
                                                                    '(|NonNegativeInteger|)
                                                                    #2#))
                                                 (QREFELT $ 44))
                                                |s|)
                                               . #3#)
                                         (EXIT
                                          (COND ((ZEROP |n|) |s|)
                                                (#4#
                                                 (SEQ
                                                  (SEQ (LETT |i| 2 . #3#) G190
                                                       (COND
                                                        ((NULL
                                                          (COND
                                                           ((ZEROP |n|) 'NIL)
                                                           ('T 'T)))
                                                         (GO G191)))
                                                       (SEQ
                                                        (LETT |d|
                                                              (REMAINDER2 |n|
                                                                          10)
                                                              . #3#)
                                                        (LETT |n|
                                                              (QUOTIENT2 |n|
                                                                         10)
                                                              . #3#)
                                                        (EXIT
                                                         (COND
                                                          ((ZEROP |d|)
                                                           "iterate")
                                                          ('T
                                                           (SEQ
                                                            (LETT |m0|
                                                                  (STRCONC
                                                                   (MAKE-FULL-CVEC
                                                                    |i|
                                                                    (QREFELT $
                                                                             45))
                                                                   (STRCONC "I"
                                                                            (MAKE-FULL-CVEC
                                                                             |i|
                                                                             (QREFELT
                                                                              $
                                                                              46))))
                                                                  . #3#)
                                                            (LETT |mm|
                                                                  (SPADCALL
                                                                   (PROGN
                                                                    (LETT #1#
                                                                          NIL
                                                                          . #3#)
                                                                    (SEQ
                                                                     (LETT |j|
                                                                           1
                                                                           . #3#)
                                                                     G190
                                                                     (COND
                                                                      ((QSGREATERP
                                                                        |j|
                                                                        |d|)
                                                                       (GO
                                                                        G191)))
                                                                     (SEQ
                                                                      (EXIT
                                                                       (LETT
                                                                        #1#
                                                                        (CONS
                                                                         |m0|
                                                                         #1#)
                                                                        . #3#)))
                                                                     (LETT |j|
                                                                           (QSADD1
                                                                            |j|)
                                                                           . #3#)
                                                                     (GO G190)
                                                                     G191
                                                                     (EXIT
                                                                      (NREVERSE
                                                                       #1#))))
                                                                   (QREFELT $
                                                                            15))
                                                                  . #3#)
                                                            (COND
                                                             ((SPADCALL
                                                               (QCSIZE |s|) 0
                                                               (QREFELT $ 52))
                                                              (LETT |s|
                                                                    (STRCONC
                                                                     " " |s|)
                                                                    . #3#)))
                                                            (EXIT
                                                             (LETT |s|
                                                                   (STRCONC
                                                                    |mm| |s|)
                                                                   . #3#)))))))
                                                       (LETT |i| (QSADD1 |i|)
                                                             . #3#)
                                                       (GO G190) G191
                                                       (EXIT NIL))
                                                  (EXIT |s|))))))))))))))))))))) 

(DEFUN |NUMFMT;ScanRoman;SPi;10| (|s| $)
  (PROG (#1=#:G1891 |Max| |tot| |n| #2=#:G1883 |i| |c| |k| |nprens|)
    (RETURN
     (SEQ
      (LETT |s| (SPADCALL |s| (QREFELT $ 54)) . #3=(|NUMFMT;ScanRoman;SPi;10|))
      (LETT |tot| 0 . #3#) (LETT |Max| 0 . #3#)
      (LETT |i| (SPADCALL |s| (QREFELT $ 55)) . #3#)
      (SEQ G190
           (COND ((NULL (>= |i| (SPADCALL |s| (QREFELT $ 56)))) (GO G191)))
           (SEQ (LETT |c| (SPADCALL |s| |i| (QREFELT $ 57)) . #3#)
                (LETT |i| (- |i| 1) . #3#)
                (LETT |n| (QAREF1 (QREFELT $ 42) (SPADCALL |c| (QREFELT $ 43)))
                      . #3#)
                (COND
                 ((< |n| 0)
                  (COND
                   ((SPADCALL |c| (QREFELT $ 46) (QREFELT $ 58))
                    (|error|
                     (LIST "Improper character in Roman numeral: "
                           (SPADCALL |c| (QREFELT $ 60)))))
                   ('T
                    (SEQ (LETT |nprens| 1 . #3#)
                         (SEQ G190
                              (COND
                               ((NULL
                                 (COND
                                  ((SPADCALL |c| (QREFELT $ 46) (QREFELT $ 10))
                                   (>= |i| (SPADCALL |s| (QREFELT $ 56))))
                                  ('T 'NIL)))
                                (GO G191)))
                              (SEQ
                               (LETT |c| (SPADCALL |s| |i| (QREFELT $ 57))
                                     . #3#)
                               (LETT |i| (- |i| 1) . #3#)
                               (EXIT
                                (COND
                                 ((SPADCALL |c| (QREFELT $ 46) (QREFELT $ 10))
                                  (LETT |nprens| (+ |nprens| 1) . #3#)))))
                              NIL (GO G190) G191 (EXIT NIL))
                         (EXIT
                          (COND
                           ((SPADCALL |c| (QREFELT $ 47) (QREFELT $ 58))
                            (|error| "Improper Roman numeral: (x)"))
                           ('T
                            (SEQ
                             (SEQ (LETT |k| 1 . #3#) G190
                                  (COND
                                   ((OR (QSGREATERP |k| |nprens|)
                                        (NULL
                                         (>= |i|
                                             (SPADCALL |s| (QREFELT $ 56)))))
                                    (GO G191)))
                                  (SEQ
                                   (EXIT
                                    (SEQ
                                     (LETT |c|
                                           (SPADCALL |s| |i| (QREFELT $ 57))
                                           . #3#)
                                     (LETT |i| (- |i| 1) . #3#)
                                     (EXIT
                                      (COND
                                       ((SPADCALL |c| (QREFELT $ 45)
                                                  (QREFELT $ 58))
                                        (PROGN
                                         (LETT #2#
                                               (|error|
                                                "Improper Roman numeral: unbalanced ')'")
                                               . #3#)
                                         (GO #2#)))))))
                                   #2# (EXIT #2#))
                                  (LETT |k| (QSADD1 |k|) . #3#) (GO G190) G191
                                  (EXIT NIL))
                             (EXIT
                              (LETT |n|
                                    (SPADCALL 10 (+ |nprens| 2) (QREFELT $ 61))
                                    . #3#)))))))))))
                (EXIT
                 (COND ((< |n| |Max|) (LETT |tot| (- |tot| |n|) . #3#))
                       ('T
                        (SEQ (LETT |tot| (+ |tot| |n|) . #3#)
                             (EXIT (LETT |Max| |n| . #3#)))))))
           NIL (GO G190) G191 (EXIT NIL))
      (EXIT
       (COND
        ((< |tot| 0)
         (|error|
          (LIST "Improper Roman numeral: " (SPADCALL |tot| (QREFELT $ 62)))))
        ('T
         (PROG1 (LETT #1# |tot| . #3#)
           (|check-subtype| (> #1# 0) '(|PositiveInteger|) #1#))))))))) 

(DEFUN |NumberFormats| #1=()
  (PROG #1#
    (RETURN
     (PROG (#2=#:G1895)
       (RETURN
        (COND
         ((LETT #2# (HGET |$ConstructorCache| '|NumberFormats|)
                . #3=(|NumberFormats|))
          (|CDRwithIncrement| (CDAR #2#)))
         ('T
          (UNWIND-PROTECT
              (PROG1
                  (CDDAR
                   (HPUT |$ConstructorCache| '|NumberFormats|
                         (LIST (CONS NIL (CONS 1 (|NumberFormats;|))))))
                (LETT #2# T . #3#))
            (COND
             ((NOT #2#) (HREM |$ConstructorCache| '|NumberFormats|))))))))))) 

(DEFUN |NumberFormats;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
     (PROGN
      (LETT |dv$| '(|NumberFormats|) . #1=(|NumberFormats|))
      (LETT $ (GETREFV 64) . #1#)
      (QSETREFV $ 0 |dv$|)
      (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #1#))
      (|haddProp| |$ConstructorCache| '|NumberFormats| NIL (CONS 1 $))
      (|stuffDomainSlots| $)
      (SETF |pv$| (QREFELT $ 3))
      (QSETREFV $ 22
                (SPADCALL (SPADCALL "Float" (QREFELT $ 19)) (QREFELT $ 21)))
      (QSETREFV $ 36
                (SPADCALL
                 (LIST #2="" #3="I" "II" "III" "IV" #4="V" "VI" "VII" "VIII"
                       "IX")
                 (QREFELT $ 35)))
      (QSETREFV $ 37
                (SPADCALL
                 (LIST #2# #5="X" "XX" "XXX" "XL" #6="L" "LX" "LXX" "LXXX"
                       "XC")
                 (QREFELT $ 35)))
      (QSETREFV $ 38
                (SPADCALL
                 (LIST #2# #7="C" "CC" "CCC" "CD" #8="D" "DC" "DCC" "DCCC"
                       "CM")
                 (QREFELT $ 35)))
      (QSETREFV $ 39 0)
      (QSETREFV $ 40 0)
      (QSETREFV $ 41 0)
      (QSETREFV $ 42 (MAKEARR1 256 -1))
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL " " (QREFELT $ 8)) (QREFELT $ 43)) 0)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #3# (QREFELT $ 8)) (QREFELT $ 43)) 1)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #4# (QREFELT $ 8)) (QREFELT $ 43)) 5)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #5# (QREFELT $ 8)) (QREFELT $ 43)) 10)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #6# (QREFELT $ 8)) (QREFELT $ 43)) 50)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #7# (QREFELT $ 8)) (QREFELT $ 43)) 100)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #8# (QREFELT $ 8)) (QREFELT $ 43)) 500)
      (QSETAREF1 (QREFELT $ 42)
                 (SPADCALL (SPADCALL #9="M" (QREFELT $ 8)) (QREFELT $ 43))
                 1000)
      (QSETREFV $ 44 (SPADCALL #9# (QREFELT $ 8)))
      (QSETREFV $ 45 (SPADCALL "(" (QREFELT $ 8)))
      (QSETREFV $ 46 (SPADCALL ")" (QREFELT $ 8)))
      (QSETREFV $ 47 (SPADCALL #3# (QREFELT $ 8)))
      $)))) 

(MAKEPROP '|NumberFormats| '|infovec|
          (LIST
           '#(NIL NIL NIL NIL NIL NIL (|String|) (|Character|) (0 . |char|)
              (|Boolean|) (5 . =) (|Mapping| 7 7) (11 . |map|) (|List| $)
              (17 . |split|) (23 . |concat|) (|Mapping| 9 7) (28 . |any?|)
              (|Symbol|) (34 . |coerce|) (|SExpression|) (39 . |convert|)
              '|sexfloat| (44 . |car|) (49 . =) (55 . |cdr|) (60 . |integer?|)
              (|Integer|) (|Float|) (65 . |coerce|)
              |NUMFMT;ScanFloatIgnoreSpaces;SF;5| (|Union| 28 '"failed")
              |NUMFMT;ScanFloatIgnoreSpacesIfCan;SU;6| (|List| 6)
              (|PrimitiveArray| 6) (70 . |construct|) '|units| '|tens| '|hunds|
              '|umin| '|tmin| '|hmin| '|romval| (75 . |ord|) '|thou| '|plen|
              '|pren| '|ichar| (|PositiveInteger|) |NUMFMT;FormatArabic;PiS;7|
              |NUMFMT;ScanArabic;SPi;8| (|NonNegativeInteger|) (80 . >)
              |NUMFMT;FormatRoman;PiS;9| (86 . |upperCase|) (91 . |maxIndex|)
              (96 . |minIndex|) (101 . |elt|) (107 . ~=) (|OutputForm|)
              (113 . |coerce|) (118 . ^) (124 . |coerce|)
              |NUMFMT;ScanRoman;SPi;10|)
           '#(|ScanRoman| 129 |ScanFloatIgnoreSpacesIfCan| 134
              |ScanFloatIgnoreSpaces| 139 |ScanArabic| 144 |FormatRoman| 149
              |FormatArabic| 154)
           'NIL
           (CONS (|makeByteWordVec2| 1 'NIL)
                 (CONS '#()
                       (CONS '#()
                             (|makeByteWordVec2| 63
                                                 '(1 7 0 6 8 2 7 9 0 0 10 2 6 0
                                                   11 0 12 2 6 13 0 7 14 1 6 0
                                                   13 15 2 6 9 16 0 17 1 18 0 6
                                                   19 1 20 0 18 21 1 20 0 0 23
                                                   2 20 9 0 0 24 1 20 0 0 25 1
                                                   20 9 0 26 1 28 0 27 29 1 34
                                                   0 33 35 1 7 27 0 43 2 51 9 0
                                                   0 52 1 6 0 0 54 1 6 27 0 55
                                                   1 6 27 0 56 2 6 7 0 27 57 2
                                                   7 9 0 0 58 1 7 59 0 60 2 48
                                                   0 0 48 61 1 27 59 0 62 1 0
                                                   48 6 63 1 0 31 6 32 1 0 28 6
                                                   30 1 0 48 6 50 1 0 6 48 53 1
                                                   0 6 48 49)))))
           '|lookupComplete|)) 

(MAKEPROP '|NumberFormats| 'NILADIC T) 
