If digital data is stored in 0s & 1s, how does the reader know how many of the digits to take into consideration?

942 views

Must be a very basic and dumb question. But ‘1001’ can be 9 and also 2 & 1 if ’10’ & ’01’ is taken seperately. I’m confused.

In: 49

48 Answers

Anonymous 0 Comments

The most accurate short answer is “it depends.”

At the processor level, everything is standard lengths and all the interpretation is physically wired into the chip. As an example, many ARM processors (used mostly in phones and such) operate with 32-bit long instructions. A specific part of those 32 bits contains what’s called an opcode, which tells the processor how to interpret the rest of the bits.

At the programming level, you need some way to keep track of what format each piece of data is in. If you’re programming in assembly (the lowest level language), it’s up to you and you alone to make sure everything is being read properly. In something like Java, the language makes you to choose what type of data a variable is and then keeps track of it for you. In something like Python, the interpreter automatically assigns and keeps track of it without you having to do anything.

At the file level, the program you’re feeding the data will try to read the file based on its extension. Most file types also have a “header” which is basically a special part at the start of the file that tells you about how to read it. For example, a text file will have a header that tells you which encoding it’s using, which lets the program know things like how many bits there are per letter, and which patterns mean which letters.

You are viewing 1 out of 48 answers, click here to view all answers.