Printing a hexadecimal number in ulisp?


#1

Hi

I’m looking for a way to print a number (mostly a byte) in hex notation.
Does anybody know a simple solution for this ???

Kind regards ,

Ronny Suy


#2

Here’s one way:

(defun pc (i) (princ (code-char (+ i (if (<= i 9) 48 55)))))

(defun pb (i) (pn (ash i -4)) (pn (logand i 15)))

The function pc prints a hexadecimal character, and pb prints a byte.