Is there a similar function to (parse-integer \"ff\" :radix 16) that will take me back the other way? If I have the int 255 how do I convert it to the string ff?
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
(write-to-string 255 :base 16)