HEX char -- > its comlement



Hi
what is the smartest function that maps the char on the left to
the char on the right (I want to complement an hexadecimal string,
like making a negative color).

0 -> f
1 -> e
2 -> d
3 -> c
4 -> b
5 -> a
6 -> 9
7 -> 8
8 -> 7
9 -> 6
a or A -> 5
b or B -> 4
c or C -> 3
d or D -> 2
e or E -> 1
f or F -> 0

If there is something able to map in one shot a whole string
to its "complement" would be even better.

-Pam

.



Relevant Pages

  • Re: print binary representation
    ... How can I output value of char or int in binary form with printf;? ... It accounts for ones' complement, where all bits 1 is a possible ... sign bit 1 is a representation of 0. ...
    (comp.lang.c)
  • Re: print binary representation
    ... How can I output value of char or int in binary form with printf;? ... It accounts for ones' complement, where all bits 1 is a possible ... sign bit 1 is a representation of 0. ...
    (comp.lang.c)
  • Re: hex dump?
    ... SpreadTooThin wrote: ... how would you turn it into a hexadecimal string. ... Its a char char.ToHexString? ... int i, j, k; ...
    (comp.lang.java.programmer)
  • Re: Direct computation of integer limits in K&R2?
    ... ~0 may be a trap representation on sign-magnitude machines. ... Did you mean ones' complement? ... conversion to unsigned char will produce 0) or it is a trap ...
    (comp.lang.c)
  • Re: hex dump?
    ... how would you turn it into a hexadecimal string. ... This is where I am lost.. ... Its a char char.ToHexString? ... check the Integer class. ...
    (comp.lang.java.programmer)

Loading