How to redefine HEX symbols
-
Hallo I'd like to change the chars printed unsing HEX. Sample:
int nHex = 0xABCDEF; char nHexText[7]; sprintf(nHexText,"%x",nHex); // Result for example // nHexText = ":;<=>?"; // This is [hex value] + [48] ?!?!
By now i convert as hex to string and use some macros for each char to convert. Is there any posibility to change the symbol by just using sprintf ?? THX Timen -
Hallo I'd like to change the chars printed unsing HEX. Sample:
int nHex = 0xABCDEF; char nHexText[7]; sprintf(nHexText,"%x",nHex); // Result for example // nHexText = ":;<=>?"; // This is [hex value] + [48] ?!?!
By now i convert as hex to string and use some macros for each char to convert. Is there any posibility to change the symbol by just using sprintf ?? THX Timentbrake wrote:
change the symbol
I'm not sure what symbol is referring to.
tbrake wrote:
now i convert as hex to string
On a side note, "hex" is not a number, it is a radix for representing the number value in some base or number system. You can view a number using any radix you desire. Whether you choose to look at it in base-2, 10, 16, 32 does not change the number. Anyway, if possible, please clarify your question.
-
tbrake wrote:
change the symbol
I'm not sure what symbol is referring to.
tbrake wrote:
now i convert as hex to string
On a side note, "hex" is not a number, it is a radix for representing the number value in some base or number system. You can view a number using any radix you desire. Whether you choose to look at it in base-2, 10, 16, 32 does not change the number. Anyway, if possible, please clarify your question.
hallo OK radix ... will look up this just after this mail.. I mean Displaying Hex as String measn unsing the symbols 0 1 2 3 4 5 6 7 8 9 A B C D E F Now i need 0 1 2 3 4 5 6 7 8 9 : ; < = > ? I know this is strange but i have some old hardware - this is only able to understand these symbols no hex !!! X| and the second problem is i need a very fast calculation. THX
-
hallo OK radix ... will look up this just after this mail.. I mean Displaying Hex as String measn unsing the symbols 0 1 2 3 4 5 6 7 8 9 A B C D E F Now i need 0 1 2 3 4 5 6 7 8 9 : ; < = > ? I know this is strange but i have some old hardware - this is only able to understand these symbols no hex !!! X| and the second problem is i need a very fast calculation. THX
Wait a minute, one an earlier thread today you stated...
tbrake wrote:
Hallo 1. Well at least it makes sence. cause i have to controll some hardware. To calculate the needed commands the shortes way is to interprete int as Hex bit shift this and the result is the needed command.
I apologize but this is making no sense. I would love to help but I've been burned by questions that didn't describe the problem correctly. I would spend my valuable time working out a solution to help out a fellow CP member only to find out later on that the problem context was different enough to warrant a totally different solution thus rendering my code snippets useless. Are you sure you need a character translation for the hex representation of a number?
-
hallo OK radix ... will look up this just after this mail.. I mean Displaying Hex as String measn unsing the symbols 0 1 2 3 4 5 6 7 8 9 A B C D E F Now i need 0 1 2 3 4 5 6 7 8 9 : ; < = > ? I know this is strange but i have some old hardware - this is only able to understand these symbols no hex !!! X| and the second problem is i need a very fast calculation. THX
-
does the solution require that you send the indivdual characters representing the number or sending the number itself?
I am not sure but i think i need the numeric interpretation. The controller is a GPIB card (16 BIT connector) - to the receiver there is an initialisation string send to as char "N00,TH0,V0123456789:;<=>?\n" changing anything here will end up in errors. ... ah i think i can do this like :
int hex = 0x2ABCDEF; cmd[0] = ((hex & 0x0F000000)>>24)+48; cmd[1] = ((hex & 0x00F00000)>>20)+48; cmd[2] = ((hex & 0x000F0000)>>16)+48; cmd[3] = ((hex & 0x0000F000)>>12)+48; ...
OK i try this :cool: THX Timen