Elisp: Number

By Xah Lee. Date: . Last updated: .

Basic Number Types

Scientific Input

1e3
;; 1000.0

1e6
;; 1000000.0

Binary, Hexadecimal, Octal, Input

;; binary input

#b0
;; 0

#b1
;; 1

#b10
;; 2

#b11
;; 3
;; hexadecimal ff
#xff
;; 255
;; octal
#o77
;; 63

Arbitrary Number Base Input Form

emacs lisp support literal input of number of arbitrary number base, using the English alphabet as 26 additional digits.

syntax:

#radixrnum

For example, for hexadecimal f, the syntax is #16rf

;; emacs lisp support literal input of arbitrary number base
;; syntax
;; #‹radix›r‹num›

;; base 16
#16r9 ; 9
#16ra ; 10
#16rb ; 11
#16rc ; 12
#16rd ; 13
#16re ; 14
#16rf ; 15

;; base 17
#17r1 ;  1
#17r2 ;  2
#17r3 ;  3
#17r4 ;  4
#17r5 ;  5
#17r6 ;  6
#17r7 ;  7
#17r8 ;  8
#17r9 ;  9
#17ra ; 10
#17rb ; 11
#17rc ; 12
#17rd ; 13
#17re ; 14
#17rf ; 15
#17rg ; 16
#17r10 ; 17
#17r11 ; 18

Reference

Elisp, Numbers