Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Dialog Controls Palette Pin
David Crow7-Aug-06 8:40
David Crow7-Aug-06 8:40 
AnswerRe: Dialog Controls Palette Pin
anu_887-Aug-06 18:32
anu_887-Aug-06 18:32 
Questionsetup via CD/web Pin
Tara147-Aug-06 6:45
Tara147-Aug-06 6:45 
AnswerRe: setup via CD/web Pin
Varchas R S7-Aug-06 10:11
Varchas R S7-Aug-06 10:11 
GeneralRe: setup via CD/web Pin
Tara147-Aug-06 20:48
Tara147-Aug-06 20:48 
QuestionHow do i get the full path from a into a exe loaded/injected dll(module)? Pin
kefir0077-Aug-06 6:44
kefir0077-Aug-06 6:44 
Questionflushing extra key presses Pin
Biboc7-Aug-06 5:53
Biboc7-Aug-06 5:53 
Questionconverting hex to binary string Pin
flippydeflippydebop7-Aug-06 5:21
flippydeflippydebop7-Aug-06 5:21 
i wonder if someone could help me with an issue im having converting a hex value to a binary string..

i am trying to convert the hex string 0x00C000000000 to binary which should work out to be 1100000000000000000000000000000000000000.

i am using std::stringstream to fist convert the hex value to decimal and this is where it seems to be failing.. for the hex string 0x00C000000000 the decimal equivalent should be 824633720832 but i am not getting that..

here is my code

	// hex = 0x00C000000000<br />
	// dec = 824633720832<br />
	// bin = 1100000000000000000000000000000000000000<br />
<br />
<br />
	std::string hexvalue = "00C000000000";<br />
	std::string binary = "";<br />
<br />
	long decimalVal;<br />
	<br />
	std::stringstream sstr(hexvalue);<br />
	sstr >> std::hex >> decimalVal;<br />
<br />
	// now convert decimalVal to binary<br />
	std::ostringstream out;<br />
	long digit;<br />
	bool nonzero = false;<br />
<br />
	for (long i = 31; i >=0; i--)<br />
	{<br />
		digit = (decimalVal >> i) & 1 ;<br />
		if (!nonzero && digit)<br />
			nonzero = true;<br />
<br />
		if (nonzero)<br />
			out << digit;<br />
	}<br />
<br />
	binary = out.str();


by the way, if i set hexvalue to a smaller number then it seems to work. for example.

std::string hexvalue = "12";

can anybody help me out here?

thanks in advance
AnswerRe: converting hex to binary string [modified] Pin
flippydeflippydebop7-Aug-06 5:25
flippydeflippydebop7-Aug-06 5:25 
QuestionNT Service - working directory Pin
yoti117-Aug-06 5:20
yoti117-Aug-06 5:20 
AnswerRe: NT Service - working directory Pin
Michael Dunn7-Aug-06 7:26
sitebuilderMichael Dunn7-Aug-06 7:26 
AnswerRe: NT Service - working directory Pin
David Crow7-Aug-06 8:15
David Crow7-Aug-06 8:15 
AnswerRe: NT Service - working directory Pin
Vipin Aravind7-Aug-06 8:59
Vipin Aravind7-Aug-06 8:59 
AnswerRe: NT Service - working directory Pin
Hamid_RT8-Aug-06 6:37
Hamid_RT8-Aug-06 6:37 
QuestionNo browse info in VS2005 Pin
Jim A. Johnson7-Aug-06 5:14
Jim A. Johnson7-Aug-06 5:14 
QuestionCDialogBar with ScrollBar [modified] Pin
hsdjusa7-Aug-06 5:00
hsdjusa7-Aug-06 5:00 
AnswerRe: CDialogBar with ScrollBar Pin
Michael Dunn7-Aug-06 7:28
sitebuilderMichael Dunn7-Aug-06 7:28 
QuestionA trouble question about the dialog Pin
xuwenq887-Aug-06 4:50
xuwenq887-Aug-06 4:50 
AnswerRe: A trouble question about the dialog Pin
Cedric Moonen7-Aug-06 5:05
Cedric Moonen7-Aug-06 5:05 
GeneralRe: A trouble question about the dialog Pin
xuwenq887-Aug-06 17:41
xuwenq887-Aug-06 17:41 
GeneralRe: A trouble question about the dialog Pin
Cedric Moonen7-Aug-06 20:19
Cedric Moonen7-Aug-06 20:19 
GeneralRe: A trouble question about the dialog Pin
xuwenq8812-Aug-06 5:27
xuwenq8812-Aug-06 5:27 
Questionpacket Filtering with Pfbindinterfacetoindex Pin
_tasleem7-Aug-06 4:16
_tasleem7-Aug-06 4:16 
AnswerRe: packet Filtering with Pfbindinterfacetoindex Pin
Viorel.7-Aug-06 4:26
Viorel.7-Aug-06 4:26 
GeneralRe: packet Filtering with Pfbindinterfacetoindex Pin
_tasleem7-Aug-06 19:18
_tasleem7-Aug-06 19:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.