Click here to Skip to main content
15,917,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: converting from binary number representation to floating-point representation Pin
CPallini17-Mar-09 10:09
mveCPallini17-Mar-09 10:09 
GeneralRe: converting from binary number representation to floating-point representation [modified] Pin
steve_o17-Mar-09 11:41
steve_o17-Mar-09 11:41 
GeneralRe: converting from binary number representation to floating-point representation Pin
CPallini17-Mar-09 11:55
mveCPallini17-Mar-09 11:55 
GeneralRe: converting from binary number representation to floating-point representation Pin
Stuart Dootson17-Mar-09 13:36
professionalStuart Dootson17-Mar-09 13:36 
GeneralRe: converting from binary number representation to floating-point representation [modified] Pin
steve_o17-Mar-09 17:07
steve_o17-Mar-09 17:07 
QuestionRe: converting from binary number representation to floating-point representation Pin
CPallini17-Mar-09 22:42
mveCPallini17-Mar-09 22:42 
GeneralRe: converting from binary number representation to floating-point representation Pin
Stuart Dootson17-Mar-09 23:12
professionalStuart Dootson17-Mar-09 23:12 
GeneralRe: converting from binary number representation to floating-point representation Pin
steve_o18-Mar-09 11:08
steve_o18-Mar-09 11:08 
Great, thank you. I changed the output to cout << (significand * sign) * (pow(2.0, exp)) << endl; which obviously just gives the floating point value once multiplied out.

After finishing this function I noticed that my one's and two's complement representation function is not working correctly. Any help would be greatly appreciated. Thanks.

void valueONESTWOS(bool input[], int n)
{
	bool tempBin[8];
	int intVal;

	// Copies "input" array to "tempBin" array
	for(int z=0; z<8; z++)
		tempBin[z] = input[z];
	intVal = valueUINT(tempBin, 8);

	// If the sign bit is 1, the value is negative.
	// The while loops NEG the binary array.
	if(tempBin[0] == 1)
	{
		int i = 7;
		while(tempBin[i] != 1)
			i--;
		while(i>=0)
		{
			if(tempBin[i] == 1)
				tempBin[i] = 0;
			else if(tempBin[i] == 0)
				tempBin[i] = 1;
			i--;
		}
		//tempBin[7] = (tempBin[7] == 1); dont need this
		cout << "One's complement: " << "-" << valueUINT(tempBin, 8) << endl;
		cout << "Two's complement: " << "-" << valueUINT(tempBin, 8) + 1 << endl;
	}

	// If sign bit is 0, the value is positive.
	else
	{
		cout << "One's Complement: " << intVal << endl;
		cout << "Two's Complement: " << intVal << endl;
	}

}

GeneralRe: converting from binary number representation to floating-point representation Pin
Stuart Dootson18-Mar-09 14:11
professionalStuart Dootson18-Mar-09 14:11 
QuestionChange Image in Excel Picture Object Pin
Sister Ray17-Mar-09 7:54
Sister Ray17-Mar-09 7:54 
QuestionWM_WINDOWPOSCHANING?? Pin
sam_psycho17-Mar-09 6:15
sam_psycho17-Mar-09 6:15 
AnswerRe: WM_WINDOWPOSCHANING?? Pin
Akt_4_U17-Mar-09 6:45
Akt_4_U17-Mar-09 6:45 
GeneralRe: WM_WINDOWPOSCHANING?? Pin
sam_psycho17-Mar-09 6:59
sam_psycho17-Mar-09 6:59 
GeneralRe: WM_WINDOWPOSCHANING?? Pin
David Crow17-Mar-09 9:04
David Crow17-Mar-09 9:04 
Questionwindows environment Pin
anassamar17-Mar-09 6:06
anassamar17-Mar-09 6:06 
AnswerRe: windows environment Pin
Code-o-mat17-Mar-09 6:13
Code-o-mat17-Mar-09 6:13 
QuestionRe: windows environment Pin
David Crow17-Mar-09 6:40
David Crow17-Mar-09 6:40 
AnswerRe: windows environment Pin
anassamar18-Mar-09 3:21
anassamar18-Mar-09 3:21 
GeneralRe: windows environment Pin
David Crow18-Mar-09 3:23
David Crow18-Mar-09 3:23 
AnswerRe: windows environment Pin
bulg17-Mar-09 6:58
bulg17-Mar-09 6:58 
QuestionUpdate CListCtrl Pin
durban217-Mar-09 4:17
durban217-Mar-09 4:17 
Questionbitwise Pin
mac_g17-Mar-09 3:57
mac_g17-Mar-09 3:57 
AnswerRe: bitwise Pin
David Crow17-Mar-09 4:07
David Crow17-Mar-09 4:07 
GeneralRe: bitwise Pin
mac_g17-Mar-09 4:10
mac_g17-Mar-09 4:10 
GeneralRe: bitwise Pin
mac_g17-Mar-09 4:58
mac_g17-Mar-09 4:58 

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.