• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

PI in binary

Help.

How does pi in binary corelate to normal binary numbers?
ie
      11.00100100001111110110
I can see the binary 3.
11.
11 = 3 in binary.  I got it...

but 1 = 1 in binary.  and 4 = 100.  
where does that fit in?
0
livegirllove
Asked:
livegirllove
2 Solutions
 
JimBrandleyCommented:
If this were some BinaryCodedDecimal encoding scheme for floating point values, your interpretation would be correct. However, if this is a dump of a binary floating point value, you can treat it as a series of sums to get the correct result, as:
   1 * (2^ 1)
+ 1 * (2^0)
+ 0 * (2 ^ -1)
+ 0 * (2 ^ -2)
+ 1 * (2 ^ -3)

etc, decrementing the power of two by one for each successive binary digit.

Jim

0
 
livegirlloveAuthor Commented:
whoa.  LOL  you are going to have to dumb that one down for me.  That's basically what I saw on google.  my problem is I tried to do the math my self and cant come up with the same answer.
Can you show me just 3.14 in binary and how you got to the answer.

thanks
0
 
JimBrandleyCommented:
It might be easier if we expand the multiplications. So:
   1 * (2)
+ 1 * (1)
+ 0 * (.5)
+ 0 * (.25)
+ 1 * (.125)
skipping some zeros...
+ 1 * (.015625)
skipping some more...
+ 1 * (.00048828125)

So far the sum is 2 + 1 + .125 + .015625 + .00048828125 = 3.14111328125

Does that help?

Jim
0
 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

 
JimBrandleyCommented:
BTW,  that was not 3.14 exactly. Those were the most significant bits you supplied for Pi. I do not have an easy way to get a dump of a binary representation for the value 3.14 any more.

Jim
0
 
Arthur_WoodCommented:
decimal fractions (.1415926) do NOT have a closed binary representation, in general.

Binary                            Decimal
-------------------------------------
.1                                   0.5   = 1/2
.01                                 0.25  = 1/4
.001                               0.125 = 1/8
.0001                             0.0625  = 1/16
.00001                           0.03125  = 1/32
.000001                         0.015625  = 1/64
.0000001                       0.0078125  = 1/128
.00000001                     0.003906125  = 1/256
.000000001                   0.0019531325  = 1/512
.0000000001                 0.0009765625  = 1/1024

and so on.

AW
0
 
Arthur_WoodCommented:
t0 512 binary digits, PI in binary is

11.
00100100 00111111 01101010 10001000 10000101 10100011 00001000 11010011
00010011 00011001 10001010 00101110 00000011 01110000 01110011 01000100
10100100 00001001 00111000 00100010 00101001 10011111 00110001 11010000
00001000 00101110 11111010 10011000 11101100 01001110 01101100 10001001
01000101 00101000 00100001 11100110 00111000 11010000 00010011 01110111
10111110 01010100 01100110 11001111 00110100 11101001 00001100 01101100
11000000 10101100 00101001 10110111 11001001 01111100 01010000 11011101
00111111 10000100 11010101 10110101 10110101 01000111 00001001 00010111


go to Google, search for "Pi in Binary"

AW
0
 
ozoCommented:
perl -e '$x=atan2(1,1)*4; for( 1..20 ){ printf"%b",int $x; $x -= int $x; $x *= 2; }'
110010010000111111011
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now