As we know, elisp supports number in different bases, e.g. #20r1j
equals to 39 in base-10. I want to display #20r1j
as #20r1j
. But (format "%d" #20r1j)
gives me 39
. How to keep the number in its original base?
As a format string, you are quite limited in the bases you can display:
%d means print as number in decimal (%o octal, %x hex).
%X is like %x, but uses upper case.
You can use the calc library to manage this for you, however:
(require 'calc-bin)
(let ((calc-number-radix 20))
(math-format-radix 39))
"1J"
(let ((calc-number-radix 20))
(math-format-radix #20r1j))
"1J"
As with the read syntax you're using, allowed values of calc-number-radix
run from 2 to 36.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With