For questions about representing numbers in base 2 or performing arithmetic on them.
Questions tagged [binary]
169 questions
19
votes
10 answers
Why does the formula 2n + 1 find the child node in a binary heap?
I learned that when you have a binary heap represented as a vector / list / array with indicies [0, 1, 2, 3, 4, 5, 6, 7, 8, ...] the indicies of the children of element at index n can be found with $leftchild = 2n + 1$ $rightchild = 2n + 2$ I can…
Keatinge
- 331
- 1
- 2
- 7
18
votes
5 answers
Signed and unsigned numbers
How would the ALU in a microprocessor differentiate between a signed number, -7 that is denoted by 1111 and an unsigned number 15, also denoted by 1111?
penguin99
- 303
- 2
- 11
15
votes
3 answers
Shannon Entropy of 0.922, 3 Distinct Values
Given a string of values $AAAAAAAABC$ , the Shannon Entropy in log base $2$ comes to $0.922$ . From what I understand, in base $2$ the Shannon Entropy rounded up is the minimum number of bits in binary to represent a single one of the values. Taken…
Sean C
- 153
- 5
9
votes
4 answers
How can I multiply a binary representation by ten using logic gates?
So I’m currently working on something and I have converted all decimal digits 0-9 into binary. But now I want to take say 6 in binary and increase its order of magnitude by base 10 (turning 6 into 60) without converting back to base 10. Is this…
user76675
- 101
- 1
- 1
- 5
7
votes
1 answer
Binary encoding with short bit sequences
Suppose you have n sequences of bits stacked in rows. The sequences can repeat along their row indefinitely. The goal is to select n sequences such that the following are both true: All $2^n$ possible columns will eventually happen at least once.…
Colman Koivisto
- 225
- 1
- 5
6
votes
1 answer
Could a standardized ternary system be more efficient than the binary system?
Could a standardized ternary (base-3) system be more efficient than the binary (base-2) system? Binary is efficient for processing using logic gates, but can be bulky when using for file storage or file transfer. I am interested in the feasibility…
JaceVoracek
- 63
- 4
6
votes
2 answers
How do computers *really* work? (at the most basic level)
While learning about computers I will read about RAM and Storage and the CPU, and while these explain the architecture of a computer and how parts of a computer work together, I still don't understand the fundamental workings of a computer program.…
icantcode
- 63
- 4
6
votes
2 answers
Why does little endian apply to numbers and not to text strings?
The Portable Executable file format is the format that Windows EXE files use. It is a binary format. Numbers are in little endian form. Thus, the following hex represents the decimal number 256, not 1. 00 01 Some fields in the file format represent…
Roger Costello
- 405
- 4
- 10
6
votes
5 answers
Binary 2s Compliment Applied Twice Gives Original - How?
At the moment the maths behind binary 2s compliment seems like voodoo to me. If I take 0011 (+3) and "flip and add 1", I get 1101 (-3) If I apply the same process to 1101, ("flip and add 1"), I get back to the original positive value. How is this so?
Robin Andrews
- 285
- 4
- 18
5
votes
0 answers
Partitioning through block moves to the end
Suppose we have a binary string $s$. We wish to partition this string in a series of $0$s followed by $1$s (alternatively: we wish to sort), using only one operation: moving three consecutive elements to the end. E.g. if our string is $ABCDEFGH$ we…
orlp
- 14,088
- 1
- 27
- 42
5
votes
2 answers
Big Transition of Binary Counting in perspective of IEEE754 floating point
If I iterate over binary representations from 000...000 to 111...111 , is there a significant transition at some point? In the IEEE 754 float32 format, the position of the bits matters, where the most significant bit (MSB) is the sign bit: sign (1)…
Muhammad Ikhwan Perwira
- 620
- 5
- 15
5
votes
5 answers
What are some uses of the Thue-Morse sequence in computer science?
Note: I come from a mathematics background. The Thue-Morse sequence $t_n$ is a binary sequence that takes the value $0$ at the positive integer $n$ if the number of $1$ s in its binary expansion is even, $1$ otherwise. A definition that is closer to…
Klangen
- 1,100
- 8
- 15
5
votes
2 answers
checking '<' for two binary numbers in a cnf-formula
I want to check whether a arbitrary binary number is less or equal to another binary number in a cnf-formula. I can already construct a formula, which is not in cnf: Lets say n and m are two-digit binary numbers: $n = n_2 + n_1$ $m = m_2 + m_1,$…
Ahosiyo
- 53
- 5
3
votes
2 answers
How many unique counting functions there are for strings of N bits?
Let a counting function inc for inputs of N bits be defined as: inc(b0 | b1 ... | bN) = F0(b0) | F1(b0,b1) ... | FN(b0,b1,...bN) Where FN is a function from N bits to a bit, and such that the period of inc is 2^N . Notice that, here, we have a…
MaiaVictor
- 4,287
- 2
- 22
- 35
3
votes
1 answer
Binary code and Hamming distance
I'm learning about CRC and Hamming distance and I have three questions. Lets say we have binary code described by ($+$ refers to sum modulo $2$): \begin{alignat*}{1} a_1 &+ a_2 &+ a_3 &+ a_4 &+ a_5 &= 0\\ a_6 &+ a_7 &+ a_8 &+ a_9 &+ a_{10} &= 0\\…
Krzysiek
- 31
- 1