Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Reply

Join Date: Jun 2009
Posts: 2
Reputation: Stemack is an unknown quantity at this point 
Solved Threads: 0
Stemack Stemack is offline Offline
Newbie Poster

Binary

 
0
  #1
Jun 30th, 2009
Sorry in advance if this is in the wrong forums but I am new here and was not too sure where to post for help. Onto business I was wondering if anybody knows how to convert a number that has a decimal point in it (example: 0.31) into binary? I have been tasked to do it but everywhere I look is no help and was wondering if anybody here could shed some light onto this?

Thanks in advance,
Steve.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Binary

 
0
  #2
Jul 1st, 2009
You are talking about floating point.
Dependent upon the data format typically IEEE
32-bit SPFP Single-Precision Floating-Point
64-bit DPFP Double-Precision Floating-Point
80-bit Double-Extended Precision Floating-Point

there are three components.
A sign bit, typically the MSB.
The Exponent
and
the Mantissa.
So 1.0 in 32-bit using IEEE would be
0x3f800000
-1.0
0xbf800000

32-bit SPFP
Sign:{31} Exponent:{30...23} mantissa:{22...0}
64-bit DPFP
63 62...52 51....0
80-bit
79 78...64 62....0
There's an implied (1) bit at bit 63.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 5
Reputation: Deque is an unknown quantity at this point 
Solved Threads: 0
Deque's Avatar
Deque Deque is offline Offline
Newbie Poster

Re: Binary

 
0
  #3
Jul 2nd, 2009
e.g.: 0.25
0.25 * 2 = 0.5 --> 0*2^(-1)
0.5 * 2 = 1.0 --> 1*2^(-2)
--> (0.25)decimal = (0.01)binary
Last edited by Deque; Jul 2nd, 2009 at 3:59 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: Binary

 
0
  #4
Jul 2nd, 2009
0.25 = 0x3e800000
0.01 = 0x3c23d79a = 0.0099999998

Or fixed point BCD (2 places)
0.25
0x0000000025
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 2
Reputation: Stemack is an unknown quantity at this point 
Solved Threads: 0
Stemack Stemack is offline Offline
Newbie Poster

Re: Binary

 
0
  #5
Jul 2nd, 2009
Hey thanks mate this has helped a great deal! +rep
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC