// you’re reading...

Variable and Data Types

Representing a Byte

(Image-1) Byte

 Byte



A byte

  • Is a group of eight consecutive bits (Image-1)
  • The bits are counted from right to left starting at 0
  • Is considered as being made of two nibbles (Image-2)



 The most right bit

  • Is bit 0
  • It is called the least significant bit
  • It is also referred to as the Low Order bit, the LO bit, or LOBIT



The most left bit

  • Is bit 7
  • It is called the most significant bit
  • It is also referred to as the High Order bit, the HI bit, or HIBIT



The other bits

  • Are referred to following their positions



(Image-2)

 Two nibbles



The right nibble (Image-2)

  • Made of the right 4 bits
  • Is called the Low Order nibble or LO nibble



The left nibble (Image-2)

  • made of the left 4 bits
  • Is called the High Order nibble or HI nibble



Using the binary system

  • you can represent the byte using a combination of 0s and 1s (B-1)



(B-1) When all bits have a value of 0

  • The byte is represented as 00000000



(B-1) When all bits have a value of 1

  • The byte is represented as 11111111



When the number grows very large

  • It becomes difficult to read. Therefore, we will represent bits in groups of four (B-2)



(B-2) Instead of writing 00000000

  • We will write it as  0000 0000



Create combinations of bits using the boxes as we did for the nibble

  • 28, which is 256.
  • There are 256 possible combinations.



Another way to find it out is by using the base 2 technique:

  • 27 + 26 + 25 + 24 + 23 + 22 + 21 + 20
    = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
    = 255
  • Therefore, the maximum decimal value you can store in a byte is 255



Remember that the byte with all bits having a value of 0

  • Has its value set to 0
  • Since this byte also holds a valid value, the number of combinations = 255 + 1 = 256



When a byte is completely represented with 0s

  • It provides the minimum value it can hold
  • This is 0000 0000, which is also 0



When all bits have a value of 1

  • Which is 1111 1111, a byte holds its maximum value that we calculated as 255 in the decimal system
  • As done with the nibble, we get the following table (Image-3):



(Image-3)

Table



The minimum storage area offered by the (Intel) computer

  • Is the byte



As you know already

  • A byte is a group of 8 consecutive bits



The amount of memory space offered by a byte

  • Can be used to store just a single symbol, such as those you see on your keyboard



These symbols, also called characters, have been organized

  • The American Standard Code for Information Exchange (ASCII) in a set list
  • But, ASCII uses only 128 decimal numbers (based on a 7-bit format) to represent symbols counted from 0 to 127
  • To compensate for the remaining 1 bit, IBM used it to organize special characters, foreign language characters, mathematical symbols, small graphics, etc
  • Each one of these characters has a decimal, a hexadecimal, and a binary equivalents



Each one of the characters you see on your keyboard

  • Is represented as a numeric value, but whether it appears as a number, a letter, or a symbol, each one of these is considered a character



To display any character on your screen

  • you can use the cout << operator and include the character between single-quotes, as (A-1)



Example of (A-1)

#include <iostream>
 
using namespace std;
 
int main()
{
 
     cout << 'a';
 
     return 0;
 
}

Discussion

No comments for “Representing a Byte”

Post a comment