众所周知,elisp 支持不同基数的数字,例如#20r1j
在 base-10 中等于 39。我想显示#20r1j
为#20r1j
. 但是(format "%d" #20r1j)
给我39
。如何将数字保持在其原始基数?
问问题
871 次
1 回答
13
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.
于 2012-04-28T04:57:40.527 回答