Простые типы / Числа / Integer

;; decimal number system
(def n-decimal 42)

;; octal number system
(def octal 042)          ; octal is 34
(def octal2 8r52)        ; octal2 is 42

;; hexadecimal number system
(def hexadecimal 0x42)   ; hexadecimal is 66
(def hex2 16r2A)         ; hex2 is 42

;; binary number system
(def binary 2r1010)      ; binary is 10

;; a string in any radix from 2 to 36
(def from-string (Integer/parseInt "2a" 16))  ; from-string is 42

;; 42 to a string in each system
(def s-decimal (str 42))                ; "42"
(def s-octal (Long/toString 42 8))      ; "52"
(def s-hex (Long/toString 42 16))       ; "2a"
(def s-binary (Long/toString 42 2))     ; "101010"

(println n-decimal octal octal2 hexadecimal hex2 binary from-string)
(prn s-decimal s-octal s-hex s-binary)