Click here to Skip to main content
15,919,358 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionconverting from binary number representation to floating-point representation Pin
steve_o17-Mar-09 9:50
steve_o17-Mar-09 9:50 
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 
This should work.

void valueFP(bool input[], int n)
{
   // I'm assuming input is 8 long
   const int sign = input[0]?-1 : 1;
   const int expCoded = (input[1]?4 : 0) + (input[2]?2 : 0) + (input[3]?1 : 0);
   const bool denormalized = (expCoded==0) || (expCoded==7);
   const int expDecoded = (expCoded^(denormalized?1 : 0)) - 3;
   const double significand = (input[4]?0.5 : 0) + (input[5]?0.25 : 0) + 
                              (input[6]?0.125 : 0) + (input[7]?0.0625 : 0) +
                              (denormalized?0.0 : 1.0);


   cout << (significand * sign) << " x 2^" << expDecoded << endl;
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: converting from binary number representation to floating-point representation Pin
steve_o18-Mar-09 11:08
steve_o18-Mar-09 11:08 
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 

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.