
(/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))
                 . #0=(|NUMFMT;contract|))
           (LETT |s|
                 (SPADCALL (CONS (|function| |NUMFMT;replaced|) $) |s|
                     (QREFELT $ 12)) . #0#)
           (LETT |ls|
                 (SPADCALL |s| (SPADCALL " " (QREFELT $ 8))
                     (QREFELT $ 14)) . #0#)
           (EXIT (LETT |s| (SPADCALL |ls| (QREFELT $ 15)) . #0#)))))) 

(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)
          ('T 'NIL)))
       ('T 'T)))
    ('T 'NIL))) 

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

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

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

(DEFUN |NUMFMT;ScanFloatIgnoreSpacesIfCan;SU;6| (|s| $)
  (PROG (|sex| |sCheck| |f|)
    (RETURN
      (SEQ (LETT |s| (|NUMFMT;contract| |s| $)
                 . #0=(|NUMFMT;ScanFloatIgnoreSpacesIfCan;SU;6|))
           (COND
             ((NULL (|NUMFMT;check| |s| $)) (EXIT (CONS 1 "failed"))))
           (LETT |sex|
                 (|interpret|
                     (|packageTran| (|ncParseFromString| |s|))) . #0#)
           (LETT |sCheck|
                 (SPADCALL (SPADCALL |sex| (QREFELT $ 23))
                     (QREFELT $ 23)) . #0#)
           (EXIT (COND
                   ((|BooleanEquality|
                        (SPADCALL |sCheck| (QREFELT $ 22)
                            (QREFELT $ 24))
                        'T)
                    (LETT |f|
                          (CONS 0
                                (SPADCALL
                                    (SPADCALL |sex| (QREFELT $ 25))
                                    (QREFELT $ 25))) . #0#))
                   ((|BooleanEquality|
                        (SPADCALL (SPADCALL |sex| (QREFELT $ 25))
                            (QREFELT $ 26))
                        'T)
                    (SEQ (LETT |f|
                               (SPADCALL |sex| (QREFELT $ 25)) . #0#)
                         (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 (#0=#:G1865 |i| |d| |n| |m0| #1=#:G1878 |j| |mm| |s|)
    (RETURN
      (SEQ (LETT |n| |pn| . #2=(|NUMFMT;FormatRoman;PiS;9|))
           (LETT |d| (+ (REMAINDER2 |n| 10) (QREFELT $ 39)) . #2#)
           (LETT |n| (QUOTIENT2 |n| 10) . #2#)
           (LETT |s| (ELT (QREFELT $ 36) |d|) . #2#)
           (EXIT (COND
                   ((ZEROP |n|) |s|)
                   ('T
                    (SEQ (LETT |d|
                               (+ (REMAINDER2 |n| 10) (QREFELT $ 40)) . #2#)
                         (LETT |n| (QUOTIENT2 |n| 10) . #2#)
                         (LETT |s|
                               (STRCONC (ELT (QREFELT $ 37) |d|) |s|) . #2#)
                         (EXIT (COND
                                 ((ZEROP |n|) |s|)
                                 ('T
                                  (SEQ (LETT |d|
                                        (+ (REMAINDER2 |n| 10)
                                         (QREFELT $ 41)) . #2#)
                                       (LETT |n|
                                        (QUOTIENT2 |n| 10) . #2#)
                                       (LETT |s|
                                        (STRCONC
                                         (ELT (QREFELT $ 38) |d|) |s|) . #2#)
                                       (EXIT
                                        (COND
                                          ((ZEROP |n|) |s|)
                                          ('T
                                           (SEQ
                                            (LETT |d|
                                             (REMAINDER2 |n| 10) . #2#)
                                            (LETT |n|
                                             (QUOTIENT2 |n| 10) . #2#)
                                            (LETT |s|
                                             (STRCONC
                                              (MAKE-FULL-CVEC
                                               (PROG1
                                                (LETT #0# |d| . #2#)
                                                 (|check-subtype|
                                                  (>= #0# 0)
                                                  '(|NonNegativeInteger|)
                                                  #0#))
                                               (QREFELT $ 47))
                                              |s|) . #2#)
                                            (EXIT
                                             (COND
                                               ((ZEROP |n|) |s|)
                                               ('T
                                                (SEQ
                                                 (SEQ
                                                  (LETT |i| 2 . #2#)
                                                  G190
                                                  (COND
                                                    ((NULL
                                                      (COND
                                                        ((ZEROP |n|)
                                                         'NIL)
                                                        ('T 'T)))
                                                     #3=(GO G191)))
                                                  (SEQ
                                                   (LETT |d|
                                                    (REMAINDER2 |n| 10) . #2#)
                                                   (LETT |n|
                                                    (QUOTIENT2 |n| 10) . #2#)
                                                   (EXIT
                                                    (COND
                                                      ((ZEROP |d|)
                                                       "iterate")
                                                      ('T
                                                       (SEQ
                                                        (LETT |m0|
                                                         (STRCONC
                                                          (MAKE-FULL-CVEC
                                                           |i|
                                                           (QREFELT $
                                                            48))
                                                          (STRCONC "I"
                                                           (MAKE-FULL-CVEC
                                                            |i|
                                                            (QREFELT $
                                                             49)))) . #2#)
                                                        (LETT |mm|
                                                         (SPADCALL
                                                          (PROGN
                                                            (LETT #1#
                                                             NIL . #2#)
                                                            (SEQ
                                                             (LETT |j|
                                                              1 . #2#)
                                                             G190
                                                             (COND
                                                               ((QSGREATERP
                                                                 |j|
                                                                 |d|)
                                                                #3#))
                                                             (SEQ
                                                              (EXIT
                                                               (LETT
                                                                #1#
                                                                (CONS
                                                                 |m0|
                                                                 #1#) . #2#)))
                                                             (LETT |j|
                                                              (QSADD1
                                                               |j|) . #2#)
                                                             #4=(GO
                                                                 G190)
                                                             G191
                                                             (EXIT
                                                              (NREVERSE0
                                                               #1#))))
                                                          (QREFELT $
                                                           15)) . #2#)
                                                        (COND
                                                          ((< 0
                                                            (QCSIZE
                                                             |s|))
                                                           (LETT |s|
                                                            (STRCONC
                                                             " " |s|) . #2#)))
                                                        (EXIT
                                                         (LETT |s|
                                                          (STRCONC |mm|
                                                           |s|) . #2#)))))))
                                                  (LETT |i|
                                                   (QSADD1 |i|) . #2#)
                                                  #4# G191 (EXIT NIL))
                                                 (EXIT |s|))))))))))))))))))))) 

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

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

(DEFUN |NumberFormats;| ()
  (PROG (|dv$| $ |pv$|)
    (RETURN
      (PROGN
        (LETT |dv$| '(|NumberFormats|) . #0=(|NumberFormats|))
        (LETT $ (GETREFV 64) . #0#)
        (QSETREFV $ 0 |dv$|)
        (QSETREFV $ 3 (LETT |pv$| (|buildPredVector| 0 0 NIL) . #0#))
        (|haddProp| |$ConstructorCache| '|NumberFormats| NIL
            (CONS 1 $))
        (|stuffDomainSlots| $)
        (QSETREFV $ 22
            (SPADCALL (SPADCALL "Float" (QREFELT $ 19)) (QREFELT $ 21)))
        (QSETREFV $ 36
            (SPADCALL
                (LIST "" "I" "II" "III" "IV" "V" "VI" "VII" "VIII"
                      "IX")
                (QREFELT $ 35)))
        (QSETREFV $ 37
            (SPADCALL
                (LIST "" "X" "XX" "XXX" "XL" "L" "LX" "LXX" "LXXX"
                      "XC")
                (QREFELT $ 35)))
        (QSETREFV $ 38
            (SPADCALL
                (LIST "" "C" "CC" "CCC" "CD" "D" "DC" "DCC" "DCCC"
                      "CM")
                (QREFELT $ 35)))
        (QSETREFV $ 39 0)
        (QSETREFV $ 40 0)
        (QSETREFV $ 41 0)
        (QSETREFV $ 45 (SPADCALL 256 -1 (QREFELT $ 44)))
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL " " (QREFELT $ 8)) (QREFELT $ 46))
                0)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "I" (QREFELT $ 8)) (QREFELT $ 46))
                1)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "V" (QREFELT $ 8)) (QREFELT $ 46))
                5)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "X" (QREFELT $ 8)) (QREFELT $ 46))
                10)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "L" (QREFELT $ 8)) (QREFELT $ 46))
                50)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "C" (QREFELT $ 8)) (QREFELT $ 46))
                100)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "D" (QREFELT $ 8)) (QREFELT $ 46))
                500)
        (SETELT (QREFELT $ 45)
                (SPADCALL (SPADCALL "M" (QREFELT $ 8)) (QREFELT $ 46))
                1000)
        (QSETREFV $ 47 (SPADCALL "M" (QREFELT $ 8)))
        (QSETREFV $ 48 (SPADCALL "(" (QREFELT $ 8)))
        (QSETREFV $ 49 (SPADCALL ")" (QREFELT $ 8)))
        (QSETREFV $ 50 (SPADCALL "I" (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| (|NonNegativeInteger|)
             (|PrimitiveArray| 27) (75 . |new|) '|romval| (81 . |ord|)
             '|thou| '|plen| '|pren| '|ichar| (|PositiveInteger|)
             |NUMFMT;FormatArabic;PiS;7| |NUMFMT;ScanArabic;SPi;8|
             |NUMFMT;FormatRoman;PiS;9| (86 . |upperCase|)
             (91 . |maxIndex|) (96 . |minIndex|) (101 . |elt|)
             (107 . **) (|OutputForm|) (113 . |coerce|)
             (118 . |coerce|) |NUMFMT;ScanRoman;SPi;10|)
          '#(|ScanRoman| 123 |ScanFloatIgnoreSpacesIfCan| 128
             |ScanFloatIgnoreSpaces| 133 |ScanArabic| 138 |FormatRoman|
             143 |FormatArabic| 148)
          '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 2 43 0
                                  42 27 44 1 7 27 0 46 1 6 0 0 55 1 6
                                  27 0 56 1 6 27 0 57 2 6 7 0 27 58 2
                                  51 0 0 51 59 1 7 60 0 61 1 27 60 0 62
                                  1 0 51 6 63 1 0 31 6 32 1 0 28 6 30 1
                                  0 51 6 53 1 0 6 51 54 1 0 6 51 52)))))
          '|lookupComplete|)) 

(MAKEPROP '|NumberFormats| 'NILADIC T) 
