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

1703 questions
2
votes
1 answer

Formula providing binary numbers based on digit 1 occurences

I would like to find a formula which gives me all binary numbers which contain the digit "1" a certain number of times. For example to times as in this sequence: 11,101,110,1001,1010,1100,10001,... I only found a formular with two occurences of the…
xampper
  • 23
  • 3
2
votes
1 answer

How convert 1/2 to binary?

How convert 1/2 to binary? isn't it 0.1111 $1/2$ result $0$ $(1/2)*2=1$ result $0.1$ $2*2>1$ result $0.11 $ etc.
2
votes
4 answers

Mathematically get $n$th bit from integer

Most programming languages have functions for getting bits but I need to do it on a calculator so I need to understand how to do it mathematically. Basically I need a formula for getting the $n$th bit from and integer, $i$. So given: $i = 6$ and $n…
Stoopkid
  • 135
  • 1
  • 3
2
votes
1 answer

Powers of 10 in binary expansion

I noticed an interesting pattern the other day. Let's take a look at the powers of 10 in binary: $10^0$ = 1 = 1 b $10^1$ = 10 = 10 10 b $10^2$ = 100 = 1100 100 b $10^3$ = 1000 = 111110 1000 b Basically, it seems that $10^n$ for any non-negative…
2
votes
4 answers

Find the number of 1s or 0s in binary representation of a number

What is the number of 1s in the binary representation of $$3\times512 + 7\times64 + 5\times8 + 3$$ Is there any shortcut for finding the number of $1's$ and $0's$ in a binary number which has been factored as above?
user106583
2
votes
2 answers

Can someone please explain the below and if it means that if x=m/2^n and if m is odd then x can be represented in binary in two ways?

Reference image containing the statement Can someone please explain the below text and what it means in simple words? From what I understood it means that if x=m/2^n and if m is odd then x can be represented in binary in two ways? But how is that…
2
votes
3 answers

Is there a general formula for the AND and OR bitwise operators?

The bitwise operators AND and OR work as follows: "a AND b" is true if both A and B are true, and "a OR b" is false if both A and B are false. However, you can also preform these operations on numbers. If we represent "true" as "1" and "false" as…
The_Animator
  • 772
  • 3
  • 23
2
votes
0 answers

Number of numbers up to n with k set bits

Is there a way to (efficiently) compute the number of numbers up to $n$ with $k$ set bits? Some values for low $n$ and $k$ as an example (perhaps $n$ is off by one); "#" is the number of set bits in the binary representation of $n$ ("Hamming…
2
votes
1 answer

How to check between integers a & b, if inside the binary representation of a, you can find binary of b?

I'm using this to read a two dimensional texture that has a binary mapping of colors, to represent the hidden z dimension. This is used for a shadowmap im trying to create. I use the red channel to represent the z dimension, and if there is light,…
Mika
  • 21
2
votes
1 answer

Why aren't I converting 1,564 to binary correctly?

I am trying to teach myself how to convert to binary using the subtraction method. $$ 1564-1024=540 \\ 540-512=28 \\ 28-16=12 \\ 12-8=4 \\ 4-4=0 \\ \; \\ \to 11000001100_2 $$ But $1,564 =11000011100_2\neq11000001100_2 = 1,556$ What did I do wrong to…
2
votes
1 answer

Of the first $2020$ natural numbers, how many have exactly three digits of $1$ when written in base $2$ form?

Title is the question. This is from a timed competition My strategy: 2020 in base 2 is 11111100100. Then, you can find the answer by $10 \cdot 9 + 9 \cdot 8 + 7...$. This gets me the answer 330, but it's not correct
user807252
2
votes
1 answer

Is it possible to calculate Hamming Distance as a percentage?

Hamming Distance is a way to detect text simlarity. However, Hamming Distance only returns an integer. I wonder if it is possible to calculate Hamming Distance out as a percentage. Thanks My Python code to calculate Hamming Distance hamming = 0 for…
kiwirafe
  • 123
2
votes
0 answers

Are there integers which have repeating patterns in both in base 2 and base 3?

I am looking for integers which are a (finite) repeating sequence in both base 2 and 3. That is integers which can be expressed as: $$\left(\sum_{i=1}^{M} 2^{i\cdot k}\right) \cdot s \qquad (s<2^{k})$$ and as: $$\left(\sum_{j=1}^{N} 3^{j\cdot…
Yaxlat
  • 51
2
votes
1 answer

Binary Representation of Pascal's Triangle

When I recently searched Pascal's triangle on Wolfram Mathworld, the following image appeared. Wolfram Mathworld states that this is the binary representation of Pascal's triangle. I am not very familiar with binary representation, and I am not…
Larry
  • 5,090
2
votes
2 answers

Resetting or setting certain bits on a binary number.

Hi can someone please help me understand how to set or rest certain bits. i believe it is known as masking but unsure how to proceed. I would be grateful for any help with my studies. The question is: Given numbers a) 01111001 and b) 10001010. What…
orlagh
  • 35
1 2
3
16 17