(def bytehex (i) (if (< i 16) (writec #\0)) (pr (upcase:coerce i 'string 16))) (bytehex 1) prints 01 (bytehex 242) prints F2
To get a string, you can use "tostring" with bytehex:
arc> (tostring (bytehex 1)) "01"
(def 2hex (i) (string (if (< i 16) #\0) (coerce i 'string 16))) arc> (2hex 1) "01" arc> (2hex 242) "f2"