LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   binaries and doubles (https://www.linuxquestions.org/questions/programming-9/binaries-and-doubles-593783/)

manolakis 10-22-2007 05:52 PM

binaries and doubles
 
Hi there
Does anybody know how double values are represented in a binary form.
For instance, how 10.2 can be expressed, and in reality how is this done(inside computer). Is anyway that we can use a function to return that number in a binary representation. As far as i know Java has some methods to deal with binaries. If am right we can return a binary from an integer.
Any ideas?

Thanks for your time

MensaWater 10-22-2007 06:45 PM

You can see it with bc:

Type "bc -l" to start bc with standard math library.

In the bc window type "obase=2" to set output base to 2 (binary). Input base defaults to 10 (decimal).

Then type 10.2 (decimal) - you'll see it convert the output to:
1010.0011
which is the binary equivalent.

dmail 10-22-2007 07:08 PM

I will just post some links for you to read:
<a href="http://www.validlab.com/goldberg/paper.pdf">What every computer scientist should know about floating point arithmetic </a>
<a href="http://grouper.ieee.org/groups/754/">IEEE 754 group</a>
<a href="http://babbage.cs.qc.edu/IEEE-754/Decimal.html">floating point calculator</a>
<a href="http://en.wikipedia.org/wiki/IEEE_floating-point_standard">wiki article</a>


All times are GMT -5. The time now is 11:58 AM.