how to change interpretation int - hex
-
Hallo How can i change the interpretation of a variable. Example
int text = 123456; // editable by user !! ... // On one position I need to convert to 0x123456 ...
THX Timen -
Hallo How can i change the interpretation of a variable. Example
int text = 123456; // editable by user !! ... // On one position I need to convert to 0x123456 ...
THX TimenEither write your own converter (multiply each digit with powers of 16), or convert to string using sprintf and convert back to hex using sscanf. Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
-
Either write your own converter (multiply each digit with powers of 16), or convert to string using sprintf and convert back to hex using sscanf. Cheers Steen. "To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
Steen Krogsgaard wrote:
Either write your own converter (multiply each digit with powers of 16), or convert to string using sprintf and convert back to hex using sscanf.
This makes non-sense. A number is neither in decimal, in hexa, or whatever else; it is just a number. Its representation may change but the number will always be the same. You can say 0x14 or 20 or 0b10100, all these three strings represent the same number. -- modified at 7:23 Friday 2nd June, 2006 Sorry, I misread the thread :)
Cédric Moonen Software developer
Charting control -
Hallo How can i change the interpretation of a variable. Example
int text = 123456; // editable by user !! ... // On one position I need to convert to 0x123456 ...
THX TimenHallo 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. Outherwice if you cant see the sence then become a lectural 2. int - char - hex is what i have and this is as fast doing a lot of if else combinations - well but i need somthing fast - much faster ?!?! Well the THX Timen:->
-
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. Outherwice if you cant see the sence then become a lectural 2. int - char - hex is what i have and this is as fast doing a lot of if else combinations - well but i need somthing fast - much faster ?!?! Well the THX Timen:->
tbrake wrote:
2. int - char - hex is what i have and this is as fast doing a lot of if else combinations - well but i need somthing fast - much faster ?!?!
John Simmons, 05/31/2006
-
Hallo How can i change the interpretation of a variable. Example
int text = 123456; // editable by user !! ... // On one position I need to convert to 0x123456 ...
THX Timentbrake wrote:
int text = 123456; // editable by user !! ... // On one position I need to convert to 0x123456
123456 in base-16 is 0x1E240. Use
itoa()
orsscanf()
to do the conversion.
"The largest fire starts but with the smallest spark." - David Crow
-
Hallo How can i change the interpretation of a variable. Example
int text = 123456; // editable by user !! ... // On one position I need to convert to 0x123456 ...
THX Timentbrake wrote:
How can i change the interpretation of a variable.
cout<<
hex
<<123233;//displays in hexadecimal format.
cout<<oct
<<121223;//displays in octal format.
cout<<dec
<<12323;//displays in decimal format.
Nibu thomas A Developer Programming tips[^] My site[^]