How retrieve multiple information by a single number?

Pithikos
Messages
55
Reaction score
1
I was wondering how they did come up with the way of setting permissions using the linux program chmod by just using numbers. For example:
Code:
1 is for execute
2 is for write
4 is for read

Any sum of those give a unique permission to a file:
2+4=6 Let's you write and read it.
1+4=5 Let's you execute and read it.

So is there an algorithm behind this? Say for example that I have 5 different items and I want to be able to pass a single number and the other person to understand which combination of items I made.
 
Mathematics news on Phys.org
It becomes more apparent when you write the numbers in binary notation.
0001 is for execute
0010 is for write
0100 is for read
so each permission is indicated by a single bit.

If you want write and read, you add 0001 and 0010 and get 0011, which is 6 in decimal notation.
To check if you have write permission, you only have to check the second bit again. For a computer, that is very easy: you "AND" 0011 with the permission you want to check, e.g. 0010. If it is set, you will get 0010 back, if not, you will get 0000.
 
Thank you! That is indeed easy to grasp.
However what if we want to apply the same with base 10 numbers? Then it wouldn't be practical to write down the numbers as

0000
0001
0010
0100

Because that would yield the number 111 for just three objects. Or am I missing something?
 
Pithikos said:
Thank you! That is indeed easy to grasp.
However what if we want to apply the same with base 10 numbers? Then it wouldn't be practical to write down the numbers as

0000
0001
0010
0100

Because that would yield the number 111 for just three objects. Or am I missing something?

You are correct. You would waste lots more numbers using this technique in base 10 versus base 2. That's probably why it's not used in base 10 applications...
 
In principle, it is not a problem to "waste" so many numbers, if you are just going to write them down.

However, if you want to do this on a computer, eventually you will have to convert 11110 back to binary and you would get 11011112. So whereas you only needed 3 bits before, you now need 7 bits to store exactly the same information.
 
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Fermat's Last Theorem has long been one of the most famous mathematical problems, and is now one of the most famous theorems. It simply states that the equation $$ a^n+b^n=c^n $$ has no solutions with positive integers if ##n>2.## It was named after Pierre de Fermat (1607-1665). The problem itself stems from the book Arithmetica by Diophantus of Alexandria. It gained popularity because Fermat noted in his copy "Cubum autem in duos cubos, aut quadratoquadratum in duos quadratoquadratos, et...
I'm interested to know whether the equation $$1 = 2 - \frac{1}{2 - \frac{1}{2 - \cdots}}$$ is true or not. It can be shown easily that if the continued fraction converges, it cannot converge to anything else than 1. It seems that if the continued fraction converges, the convergence is very slow. The apparent slowness of the convergence makes it difficult to estimate the presence of true convergence numerically. At the moment I don't know whether this converges or not.
Back
Top