#2 Data representation in computers

The basic number value stored in computer’s memory has 8 bit – 1 byte. This allows us to store number from 0 to 255 (00000000 – 11111111) because there are no combinations of 1 and 0 left in those 8 bits. But all systems works with largers numbers with different size. 1 byte, 2 byte, 4 byte or even 8 byte numbers. This get us an opportunity to use larger or smaller variabels due to what they will be used.

BytesRangePossible usage
10 – 255Store states 0 or 1
20 – 65535Simple stopwatch
40 – 4294967295Youtube views count
80 – 18446744073709551615Something big

The reason why we cannot use the largest variables all the time is that we don’t have memory with infinity size. For example PC or smartphone has 4GB or RAM memory but small microcontroller chip can only have 1kB what is 4 milion times smaller! Programming these devices with small RAM needs to think about size of data we want to store and then use appropriate variable size.

Pridaj komentár

Vaša e-mailová adresa nebude zverejnená. Vyžadované polia sú označené *