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}$.

1760 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
  • 927
45
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
  • 743
32
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…
31
votes
5 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
  • 605
  • 1
  • 8
  • 15
29
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…
25
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,826
  • 22
  • 76
  • 114
24
votes
2 answers

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.
23
votes
2 answers

Bitwise XOR of reciprocals of natural numbers

Out of curiosity, I am considering an interesting XOR "sum" of all reciprocals: $$X := 1 \oplus \frac{1}{2} \oplus \frac{1}{3} \oplus \frac{1}{4} \oplus \cdots= \bigoplus_{n=1}^{\infty} \frac{1}{n}$$ where $\oplus$ denotes bitwise XOR and all…
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
  • 419
20
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
  • 823
20
votes
1 answer

How many bits needed to store a number

How many bits needed to store a number $55^{2002}$ ? My answer is $2002\;\log_2(55)$; is it correct?
TOP KEK
  • 315
19
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) /…
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…
15
votes
3 answers

Modulo 2 binary division (XOR not subtracting) method

I have attached an image showing a Modulo 2 binary division. I can roughly understand the working below which is using XOR calculation but I am not sure how the answer (in red) is being computed based on the workings. I have searched the net and…
Withhelds
  • 175
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
  • 510
1
2 3
99 100