Questions tagged [binary]

Questions related with (base 2) representation of numbers and their unique properties arising out of number representation.

Binary (base $2$) represents numbers using only the digits $0$ and $1$.

We write:

$$n=\sum\limits_{k=n}^0 a_k2^k$$

to represent a nonnegative integer, so for example $27_{10}=16+8+2+1=11011_2$

To represent nonnegative real numbers, we use:

$$n=\sum\limits_{k=n}^{-m} a_k2^k$$

where $m$ can be $\infty$. So, for example $11.001_2=3.125_{10}$.

1558 questions
67
votes
19 answers

What are the names of numbers in the binary system?

The names we use are very much related to the radix we use $0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9$ zero - one - two - three - four - five - six - seven - eight -nine We repeat the names $21$ twenty one, $22$ twenty two .. and so on. This is not…
user37421
  • 917
  • 1
  • 6
  • 13
42
votes
12 answers

In plain English, why does conversion from hexadecimal to binary work so cleanly?

Why does the trick of taking the binary representation of each digit and simply concatenating them work? e.g. 0x4E == 0100 concatenated with 1110, making 01001110
52d6c6af
  • 723
  • 5
  • 13
30
votes
7 answers

Is there a way to find the log of very large numbers?

I should like to evaluate $\log_2{256!}$ or other large numbers to find 'bits' of information. For example, I'd need three bits of information to represent the seven days of the week since $\lceil \log_2{7}\rceil = 3$, but my calculator returns an…
28
votes
3 answers

What do bitwise operators look like in 3d?

The hypothetical relation is $z = \mathrm{xor}\left(x,y\right)$ where xor is any bitwise operator such as AND, OR, NAND, etc. I see that these operations may be defined for integers trivially using binary-decimal conversion. In the same way, can't…
Simon Kuang
  • 1,075
  • 9
  • 19
24
votes
8 answers

Fractions in binary?

How would you write a fraction in binary numbers; for example, $1/4$, which is $.25$? I know how to write binary of whole numbers such as 6, being $110$, but how would one write fractions?
Fernando Martinez
  • 6,458
  • 15
  • 69
  • 99
23
votes
4 answers

Why Two's Complement works

About to read computer science, I have just stumbled accross the concept of "Two's complement". I understand how to apply the "algorithm" to calculate these on paper, but I have not yet obtained an understanding of why it works. I think this site:…
Jhonny
  • 497
  • 3
  • 14
21
votes
4 answers

Representing all rational numbers between $\dfrac{1}{2}$ and $1$

How do I show that $$\dfrac{2^{\left\lfloor\frac12 a_1\right\rfloor} + 2^{\left\lfloor\frac12 a_2\right\rfloor} + \ldots + 2^{\left\lfloor\frac12 a_n \right\rfloor}}{2^{\left\lceil\frac12 a_1\right\rceil} + 2^{\left\lceil\frac12 a_2\right\rceil} +…
BookWick
  • 409
  • 1
  • 10
20
votes
1 answer

What is meaning of strict weak ordering in layman's term?

I gone through many pages using Google, but not understand exact meaning of Strict-weak Ordering term. I have this requirement while sorting strings.
Pranit Kothari
  • 436
  • 1
  • 4
  • 14
18
votes
4 answers

Why are binary representations of huge numbers about $3.3218$ times as long as their decimal representations?

Why are huge binary nubers about $3.3218$ times longer than their decimal counterpart? I thought about this when I was writing this Python code: huge_number = 21**31**3 # ** is the power operator print((len(bin(huge_number)) - 2) /…
user3105485
  • 670
  • 4
  • 20
18
votes
3 answers

How can I convert 2's complement to decimal?

Suppose I have the 2's complement, negative number 1111 1111 1011 0101 (0xFFBB5). How can I represent this as a decimal number in base 10?
Bob John
  • 773
  • 2
  • 11
  • 25
17
votes
4 answers

$N$ perfect logicians wearing hats

I once came across the following riddle: (assume $N$ to be extremely large) There are $N$ perfect logicians arranged in a vertical row. They are allowed to strategize before the game, during the game they are barred from communicating. In the…
ghosts_in_the_code
  • 1,964
  • 1
  • 13
  • 28
15
votes
3 answers

Why do we divide or multiply by 2 when converting binary?

Trying to understand the fundamentals of binary rather than just following steps, I wanted to know why do we multiply by 2 to convert a decimal (0.5, 0.25) to a binary and why do we divide by 2 when we want to convert a whole number (200) by 2?…
direprobs
  • 492
  • 3
  • 9
  • 23
14
votes
1 answer

Find $\sum_{n=1}^\infty {\frac {f(n)} {n(n+1)}}$ where $f(n)$ is the number of $1$s in $n$'s binary expansion

We are given the series $\sum_{n=1}^\infty {\frac {f(n)} {n(n+1)}}$, where $f(n)$ is such a function that it equals the sum of 1's in the binary representation of n. I'm obliged to find the sum of the series. First, I decided to explicitly prove the…
Dmitri K
  • 1,391
  • 7
  • 25
14
votes
2 answers

The sum of powers of two and two's complement – is there a deeper meaning behind this?

Probably everyone has once come across the following "theorem" with corresponding "proof": $$\sum_{n=0}^\infty 2^n = -1$$ Proof: $\sum_{n=0}^\infty q^n = 1/(1-q)$. Insert $q=2$ to get the result. Of course the "proof" neglects the condition on $q$…
celtschk
  • 41,315
  • 8
  • 68
  • 125
13
votes
1 answer

The proportion of binary digits of $\sum_{k=1}^\infty \Big\lfloor{\frac{k}{2}\sqrt{p}\Big\rfloor}\cdot2^{-k}$ equal to one, is $> 0.978$ if $p=143$.

Can you prove this? Is it true? If $p$ is an integer, is this proportion never equal to 50%? See my related question regarding this sum, here. For $p=143$, I computed the binary digits in Excel using carry-over operations implemented in Excel…
1
2 3
99 100