Common lisp integer to hex conversion

孤街浪徒 提交于 2019-12-03 12:57:43
(write-to-string 255 :base 16)

You can also use format with the ~X radix designator:

CL-USER> (format t "~X" 255)
FF
NIL

To get the leading 0x and a minimum width of, say, four padded with zeros, use

CL-USER> (format t "0x~4,'0X" 255)
0x00FF
NIL

To force the digits from 10 to 15 to be lowercase, use the case conversion directive ~( as follows:

CL-USER> (format t "0x~(~4,'0x~)" 255)
0x00ff
NIL
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!