Click here to Skip to main content
15,926,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTo convert a DAT file to a BMP file Pin
sgd.ind31-Oct-09 20:55
sgd.ind31-Oct-09 20:55 
AnswerRe: To convert a DAT file to a BMP file Pin
Code-o-mat1-Nov-09 3:00
Code-o-mat1-Nov-09 3:00 
GeneralRe: To convert a DAT file to a BMP file Pin
sgd.ind1-Nov-09 3:21
sgd.ind1-Nov-09 3:21 
GeneralRe: To convert a DAT file to a BMP file Pin
Code-o-mat1-Nov-09 3:46
Code-o-mat1-Nov-09 3:46 
Questionconvert md5 values to decimal Pin
nuttynibbles31-Oct-09 20:14
nuttynibbles31-Oct-09 20:14 
AnswerRe: convert md5 values to decimal Pin
CPallini31-Oct-09 21:20
mveCPallini31-Oct-09 21:20 
Questionreverse division to convert decimals to dinary Pin
Omegaclass31-Oct-09 19:57
Omegaclass31-Oct-09 19:57 
AnswerRe: reverse division to convert decimals to dinary Pin
CPallini31-Oct-09 21:04
mveCPallini31-Oct-09 21:04 
You should go in the opposite way, using multiplication (or bit shif, that is faster):
#include <iostream>
using namespace std;
void main()
{
	unsigned int k = 731;
	unsigned int b;
	const int SIZE = sizeof(k) << 3;
	const unsigned int MSB = 1 << (SIZE-1);
	for (b=0; b<SIZE; b++)
	{
		cout << (( MSB & k) ? 1 : 0);
		k <<= 1;
	}
	cout << endl;
}


Or

#include <iostream>
using namespace std;
void main()
{
	unsigned int k = 731;
	unsigned int b;
	const int SIZE = sizeof(k) << 3;
	const unsigned int MSB = 1 << (SIZE-1);
	bool isLeadZero= true;
	for (b=0; b<SIZE; b++)
	{
		if ( MSB & k)
		{
			isLeadZero = false;
			cout << 1;
		}
		else
		{
			if ( ! isLeadZero) cout << 0;
		}
		
		k <<= 1;
	}
	cout << endl;
}


If you need to remove heading zeroes.

Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke

[My articles]

GeneralRe: reverse division to convert decimals to dinary Pin
Omegaclass31-Oct-09 21:36
Omegaclass31-Oct-09 21:36 
GeneralRe: reverse division to convert decimals to dinary Pin
CPallini1-Nov-09 6:32
mveCPallini1-Nov-09 6:32 
GeneralRe: reverse division to convert decimals to dinary Pin
Omegaclass1-Nov-09 10:10
Omegaclass1-Nov-09 10:10 
GeneralRe: reverse division to convert decimals to dinary Pin
CPallini1-Nov-09 10:13
mveCPallini1-Nov-09 10:13 
GeneralRe: reverse division to convert decimals to dinary Pin
Omegaclass1-Nov-09 12:28
Omegaclass1-Nov-09 12:28 
AnswerRe: reverse division to convert decimals to dinary Pin
David Crow2-Nov-09 4:08
David Crow2-Nov-09 4:08 
GeneralRe: reverse division to convert decimals to dinary Pin
Omegaclass2-Nov-09 17:15
Omegaclass2-Nov-09 17:15 
QuestionRe: reverse division to convert decimals to dinary Pin
David Crow3-Nov-09 2:44
David Crow3-Nov-09 2:44 
AnswerRe: reverse division to convert decimals to dinary Pin
Omegaclass3-Nov-09 19:08
Omegaclass3-Nov-09 19:08 
QuestionUgly Numbers Error Pin
anollipian31-Oct-09 14:21
anollipian31-Oct-09 14:21 
AnswerRe: Ugly Numbers Error Pin
LunaticFringe31-Oct-09 14:30
LunaticFringe31-Oct-09 14:30 
GeneralRe: Ugly Numbers Error Pin
anollipian31-Oct-09 14:44
anollipian31-Oct-09 14:44 
GeneralRe: Ugly Numbers Error Pin
Luc Pattyn1-Nov-09 3:59
sitebuilderLuc Pattyn1-Nov-09 3:59 
QuestionRe: Ugly Numbers Error Pin
David Crow31-Oct-09 16:26
David Crow31-Oct-09 16:26 
Question2 Errors Pin
MrMcIntyre31-Oct-09 6:09
MrMcIntyre31-Oct-09 6:09 
AnswerRe: 2 Errors Pin
Chris Losinger31-Oct-09 6:10
professionalChris Losinger31-Oct-09 6:10 
AnswerRe: 2 Errors Pin
enhzflep31-Oct-09 6:17
enhzflep31-Oct-09 6:17 

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.