The Tcl expr function supports arguments written in hex notation: operands which begin with 0x are treated as integers written in hex form.
However the return value of expr is always in decimal form: expr 0xA + 0xA returns 20, not 0x14.
Is there a way to tell expr to return the hex representation?
Is there a Tcl function which converts decimal representation to hex?
the
formatcommand is what you’re after: