On Jan 31, 2012, at 12:01 PM, Richard wrote:
In article <20120131162102.GB30381 at brevard.conman.org>,
Sean Conner <spc at conman.org> writes:
A friend recently raised an issue with some code
I wrote (a hex dump
routine) saying it depended upon ASCII and thus, would break on non-ASCII
based systems (and proposed a solution, but that's beside the issue here).
I assume he's saying this because you did something like '0' + x or
'A' + x to compute the hex digits. The obvious fix is to instead
index a string by the digit value:
"0123456789abcdef"[x]
Indeed, in most systems I can think of (at least ones that support indirect addressing,
which is most aside from the tiniest of 8-bits), that'll produce faster code than the
if/then construct required otherwise.
- Dave