Search code examples
sizestoragediskbit

Why does the number 2 uses 1 byte and not 2 bits of space?


If I convert the number 2 from decimal value to binary it gives me the value '10' we can see that it is only using 2 bits one being the '1' and the second being the '0' so why does it use a full byte of space ?

enter image description here

If I open a notepad and write down '2' and save it the size will be 1 byte but 1 byte = 8 bits and we can see that the number 2 only uses 2 bits, so why is it saying that it has 1 byte?.

enter image description here

tamanho = size (portuguese translation)


Solution

  • Ok I have found that the computer takes the number 2 as 0011 0010 so now I got why it uses a full byte it is using the ascii table that uses 0011 to represent a number followed by the binary code of that number so 2 to binary would be 0010 but with 0011 in the back of it making it 0011 0010 being a total of 8 bits.