zurück   Startseite   Blog Buchregal Buchregal, eBooks Twitter E-Mail

 

Xbased Converter

(define (divCounter myvalue mybase) (/ (- myvalue (remainder myvalue mybase)) mybase))
(define (divValue myvalue mybase) (- myvalue (remainder myvalue mybase)))

(define (maxBase myvalue mybase mysbase)
  (if (> myvalue mybase)
      (maxBase myvalue (* mybase mysbase) mysbase)
      (begin
    (if (= myvalue mybase)
    mybase
    (/ mybase mysbase)
    ))))
(define (baselist myvalue mynextbase mysbase)

  (if (>=  mynextbase 1)
      (begin
    (display "; ")
    (display mynextbase)
    (display ": ")
    (display (divCounter myvalue mynextbase))
    (display " [")
    (display (divValue myvalue mynextbase))
    (display "] ")
    (newline)
         (baselist (- myvalue (divValue myvalue mynextbase)) (/ mynextbase mysbase) mysbase)
      )       #t))
(define (startit myvalue mysbase)  (baselist myvalue (maxBase myvalue mysbase mysbase) mysbase))

Example #1 Using it for the mayan numal system (vigesimal system/20-based):

(startit 1600883401 20)
; 1280000000: 1 [1280000000] 
; 64000000: 5 [320000000] 
; 3200000: 0 [0] 
; 160000: 5 [800000] 
; 8000: 10 [80000] 
; 400: 8 [3200] 
; 20: 10 [200] 
; 1: 1 [1] 
;Value: #t

Example #2 Using it for the sexagesimal sumerian numeral system (60-based):
(startit 64854876400 60)
; 46656000000: 1 [46656000000] 
; 777600000: 23 [17884800000] 
; 12960000: 24 [311040000] 
; 216000: 14 [3024000] 
; 3600: 3 [10800] 
; 60: 26 [1560] 
; 1: 40 [40] 
;Value: #t

 

 

25. März 2019     | mit scheme | scheme | lisp | old data

zurück

 

     

Startseite | Impressum | Datenschutz