Binary to floating point representation

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 1
Reputation: scuba6388 is an unknown quantity at this point 
Solved Threads: 0
scuba6388 scuba6388 is offline Offline
Newbie Poster

Binary to floating point representation

 
0
  #1
Mar 17th, 2009
I am making a program that takes a binary number (a boolean array) and gives numerous representations.

For example, Enter binary (8 bits): 10001000
-Unsigned int: 136
-Hexadecimal: 88
-Octal: 210
-Two's complement: -120
-Sign magnitude: -8
-One's complement: -119
-Excess-127: 9
-ASCII: N/A
-Pep/8: SUBX immediate
-Floating-point: -0.125

I currently have all of the representations working, except floating-point. FP format would be 1 sign bit, 3 bit exponent (excess-3), and 4 bit significand. Does anyone have any suggestions on how to go about doing this? Thanks.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 122
Reputation: kenji is an unknown quantity at this point 
Solved Threads: 8
kenji's Avatar
kenji kenji is offline Offline
Junior Poster

Re: Binary to floating point representation

 
0
  #2
Mar 17th, 2009
How about you show some work first or your not gonna get very far here.
And she said "Let there be light" and on the seveth day Windows booted.
And the crowds screamed in terror and cowered in fear for Microsoft had approached.
From the testament of 10011101
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 309
Reputation: NicAx64 will become famous soon enough NicAx64 will become famous soon enough 
Solved Threads: 18
NicAx64's Avatar
NicAx64 NicAx64 is offline Offline
Posting Whiz

Re: Binary to floating point representation

 
0
  #3
Mar 17th, 2009
I can give you the idea , but writing that entire program is up's to you.

First think that I convert 10101 to decimal. Think in simple.
= 2^0 * 1 + 2^1 * 0 + 2^2 *1 + 2^3 * 0 + 2^4 * 1 .......

so you can hard-code this , or you can implement a for loop until
you finish up to input binary number length. Just right shift by one
means multiply by two.

So you can easilly get an unsigned int.
Then start using this , you can typecast it to other data representations.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC