The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [binary]

For questions about representing numbers in base 2 or performing arithmetic on them.

Filter by
Sorted by
Tagged with
2
votes
1answer
20 views

Why does going from 2's complement (in binary) to the positive value by completing to 1 then adding 1 work?

I'm studying Computer science and this has confused me for a long time since our professor didn't give any proof. When changing from 2's complement to the positive value, we can go in reverse (by ...
0
votes
3answers
71 views

Is decimal number 8 represented as 3 bits or 4 bits in computer?

I was told by my professor that "It takes c * ln(n) bits to store a number n, where ln() is base 2 and c is a constant." Thus, to store a number 8, we need ln(8) = 3 bits(I think const c can be ...
2
votes
1answer
29 views

Conversion from octal numerical system to binary numerical system

I know that in order to convert a numeral in base-8 to a numeral in base-2 I can write each octal digit as a binary word of 3 bits. I know that 2^3 = 8 that is exactly the dimension of the base of ...
1
vote
0answers
44 views

Can we represent $\sqrt{2}$ exactly even with infinite bits in mantissa [closed]

Can we represent $\sqrt{2}$ exactly even with infinite bits in mantissa in floating point notation or otherwise. We actually have to prove this is not possible. But why can't we if we have infinite ...
2
votes
1answer
53 views

Binary representation of 129 when using 8bits for two's complement?

I have this confusion regarding binary representation of decimal value 129 (or even 128). If 8 bits are used to represent numbers when doing the two's complement, then we know that '00000000' to '...
0
votes
1answer
23 views

For signed integers, why don't representative the smallest number as all zeros in binary, and the largest as all ones?

I'm reading up on bitwise operators, complements, and two's complements, and I'm wondering why the lower limit of a range (aka lowest negative number) isn't all zeroes in binary, and the upper limit ...
0
votes
1answer
28 views

How do the bits of a certain emoji code for all the colors?

I am watching an introductory course on computer science. At one part, it starts talking about unicode and how the bits 11111011000000010. He states that that codes for a laughing/crying face emoji. ...
3
votes
1answer
97 views

Is is possible to determine if a given number is xor combination of some numbers?

I have been given a number Y which is ($a$ xor $b$ xor $c$ xor $d$ xor $e$ ) of some numbers ($a$,$b$,$c$,$d$,$e$) and another no X. Now i have to determine if X is a xor combination of ($a$,$b$,$c$,$...
2
votes
1answer
18 views

What are the sufficient conditions for weighted binary code to be self compliementary?

I was going through binary codes and found out that if the weighted binary code is self complimentary then it's weights addition will be equal to 9. Is the converse true? If not then what are the ...
0
votes
0answers
33 views

How does normalised floating point binary work with two's complement?

I'm doing AQA a-level computer science, and the specification for which states that: Exam questions on floating point numbers will use a format in which both the normalised mantissa and exponent are ...
0
votes
2answers
64 views

Float number to binary

I would like to convert 0,347 and 0,9828 to binary, how can I do that? I know that sucessive multiplication by 2 can do this, but this method seems very painful and even ineffective since the size of ...
0
votes
0answers
29 views

Converting a decimal to IEEE754 32-bit binary number

Convert 0.625 to IEEE754 32-bit binary number. 0.625 x 2 = 1.250 0.250 x 2 = 0.500 0.500 x 2 = 1.000 So, ...
0
votes
1answer
54 views

Why isn't it necessary to store an integer part of significant in IEEE754 floating point notation?

We see that there is a sign, exponent, and mantissa part for the notation. But, there is no location for the significant bit. Why isn't it necessary to store an integer part of significant in IEEE754 ...
2
votes
1answer
62 views

Prove that the next multiple of 4 is obtained using the next formula

I was reading an assembly procedure that needed to align addresses on 4 bytes boundary for performance reasons so it has used the next statement that i formulated as a theorem to be proven. Let $s$ ...
16
votes
5answers
3k views

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?
0
votes
1answer
64 views

How does operating system display decimal numbers which are stored as binary? [duplicate]

What kind of magic happen with bytes in memory?
0
votes
1answer
39 views

Storage in computers?

If i want to save something in a computer such as a number 1 that would be 001 but if i save 001 in a computer how would the computer know that 001 is 1. Should we first save the number 1 in memory ...
0
votes
0answers
31 views

Find maximal matching in tree in $O\left(\frac{n}{\log n}\right)$

As any tree can be described as a binary sequence ($i$-th bit is 0 if the edge goes down and 1 otherwise, every edge is travelled twice $-$ up and down, so such sequence's length is $2 |V| - 2$), any ...
0
votes
0answers
11 views

Convert polynomial generator to binary form for crc [duplicate]

i have the polynomial generator x^3 + x To convert to binary and i am unsure of the steps to complete. Help on how to convert various polynomials to binary would be greatly appreciated and i do not ...
2
votes
2answers
98 views

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
vote
1answer
164 views

Binary Floating Point Range/Precision for 4-bit Mantissa and 4-bit Exponent

I'm trying to understand binary floating point and using just a 4-bit mantissa and a 4-bit exponent (both 2s compliment) to keep things simple. As far as I can tell, the largest denary number I can ...
0
votes
1answer
32 views

How to transform a Infinite decimal of $\frac{23}{6}$ into binary?

How to transform a decimal of $\frac{23}{6}$ into binary? $\frac{23}{6}$ is equal to $3.83333\bar{33}$, where the digit $3$s are repeated forever. I do know how to translate finite decimal into ...
2
votes
4answers
82 views

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 ...
2
votes
0answers
21 views

How can I optimise a 8b10b encoding for maximum alignment?

Imagine you encode an 8 bit symbol as a 10 bit symbol that is sent sequentially over a wire. The goal at the receiver is to detect the byte boundary. Since there are 4 times more encoded symbols than ...
0
votes
0answers
24 views

IEEE-754 and machine numbers

I've been trying to wrap my head around machine numbers like the unit roundoff (u) and epsilon (e) in combination with the IEEE 754 standard. My textbook states some things that don't really make ...
0
votes
0answers
69 views

Worst case lower bound of binary search

For the question below, it is asking to prove the lower bound on the worst case is log(n). I have no problem proving this and the solution makes 100% sense to me. However, there is a comment at the ...
2
votes
1answer
54 views

Two's complement general formula

In college, we've seen some general formulas to compute the decimal value a of a binary representation $a_{N-1} \dots a_2 a_1 a_0$ in two's complement, $N$ being the number of bits. For $a \ge 0$ we'...
14
votes
3answers
2k views

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 ...
0
votes
1answer
31 views

Need help converting machine code

I would appreciate some help with this question. The 32 bit numbers below represent a MIPS instruction. identify the different fields and state which instruction it is. give the assembler source code ...
3
votes
2answers
40 views

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: ...
0
votes
1answer
167 views

Bytes from integer using bitwise operators

So I am extremely confused with using bitwise shifts used to extract the bytes from an integer. I find that if I do something like this... ...
2
votes
1answer
132 views

What exactly is a “binary file”?

I suspect this may be more of a concept / theory question, but, I haven't been able to wrap my brain around what exactly a binary file is. I've read links such as the below: https://en.wikipedia.org/...
5
votes
0answers
121 views

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 ...
2
votes
1answer
2k views

Confusion in 2's complement of 00000000

I'm solving the end of the chapter problems of Morris Mano's Digital Design (4th Edition, if that's relevant). In one of the problems, it is asked to simply find the 1's and 2's complement of 00000000....
0
votes
0answers
29 views

Is this the right way to convert a negative floating point number in binary using two's complement method?

I'm a cs student and i've just started learning about binary arithmetic.I have to do this homework assignement to get prepared for exams..I'm having some trouble figuring out how to convert a negative ...
2
votes
0answers
30 views

If 2's complement is the best way to represent numbers in computers, why worry about BCD and other binary codes?

I'm studying Digital Logic and Design. And in the first chapter, there's all this information about various binary codes. I did some searching on youtube and found this awesome video - https://www....
-1
votes
1answer
31 views

How can the binary OR function be computed by a MOD3 gate of constant fan-in?

I've been working on a problem and in order to prove the bigger picture, I need to understand how a binary OR function can be computed by a constant fan-in MOD3 gate. I would seem that the output ...
1
vote
1answer
90 views

what does “vector” mean in computer science?

I am trying to understand how computers work under the hood, and I came across following sentence. "Computer technology is based on electronic circuits able to process vectors of 0's and 1's. For ...
5
votes
1answer
127 views

Could a standardized ternary system be more efficient than the binary system? [duplicate]

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 ...
2
votes
2answers
153 views
0
votes
2answers
229 views

Fast searching through bitarray?

I've been thinking for some time but can't figure a way out. I have big bitarray i.e. 1000+ items of 10_000 bits strings, I'm searching them now linearly. (currently it is stored in one chunk of ...
2
votes
1answer
228 views

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 &+ ...
5
votes
4answers
3k views

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 $...
0
votes
1answer
360 views

Logic Circuits - Binary divisible by 16 [closed]

I have a question ...
0
votes
0answers
50 views

Avoiding overflow when comparing between 16-bit numbers

Let's say I have a 16-bit number system. and let $a, b$ a 16-bit numbers in this system. I know that the numbers I can represent in this system are between $−32,768$ and $32,767$. Let's say I want ...
3
votes
1answer
746 views

Computing Hamming Distance Between Binary Vectors

Consider the following problem: Input: We are given a set $S$ of $n$ binary vectors. A binary vector is of the form $(b_0, b_1, ... b_n)$, where $b_i \in \{0, 1\}$. Therefore, there are $n$ vectors ...
1
vote
1answer
40 views

Converting a 32-bit bit pattern into floating point number

In The Scientist and Engineer's Guide to Digital Signal Processing By Steven W. Smith, Ph.D. i have read something like that, Single precision or 32-bit floating point forms the floating point number,...
0
votes
1answer
413 views

Assembly language translation to machine code (process in “RAM”) [closed]

How does a assembler (at very basic level) work in translation of Assembly language to machine code ? Just want to know that what is happening in RAM ? [What my understanding is that when when I ...
1
vote
1answer
209 views

n-bit 2's Complement Conversion

I'm learning 2's complement conversion for positional number systems. For the most part I have only seen 2's complement for represented in 8-bits. I had a discussion with a friend who explained that ...
8
votes
4answers
5k views

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) ...