Binary: bits, nibbles, bytes, and integers

a base 2 notation system for representing data
(Base of 2 means one character can represent up to 2 different values
e.g. in everyday math, we typically use decimal notation, base 10, meaning one character can represent 10 different values, 0-9)

the importance of bits and binary with respect to computers is that computers only understand 0 or 1’s (on or off, base 2) so many other notations like decimals (base 10) or hexadecimals (base 16) are used to interpret binary more succinctly (hexadec), or for human comfort (decimals)

Defining bits, nibbles, bytes, and integers

bits, nibbles, bytes, and integers are all groupings of data in binary (0’s and 1’s of different length, see specific definitions of each below)

These groupings of data must be associated with a type to be able to interpret the value
(e.g. nibble 1001 could mean 9 if type unsigned or -4 if type signed)

Bits

a bit is a binary digit (0 off or 1 on) which is a notation system with base of 2
(Base of 2 means one character can represent up to 2 different values
e.g. in everyday math, we typically use decimal notation, base 10, meaning one character can represent 10 different values, 0-9)

Often, we define most significant bit as left most bit (highest value bit)
and least significant bit as right most bit (lowest value bit)

Nibble

a hard definition of 4 bits long (i.e. its alway 4 bits long, unlike integers which are a general term of size n bits)
e.g. 1001 (it’s important that the type of nibble is defined, as 1001 could mean 9 if unsigned integer or -4 if signed)

1001 \mbox{ is binary notation, consider it an unsigned integer}\\ \mbox{i.e. } 1001 = 1001_2 \\ \\ \mbox{Converting to decimal notation}\\ 1001_2 = 1*(2^3) + 0*(2^2) + 0*(2^1) + 1*(2^0) \\ 1001_2 = (8) + (0) + (0) + (1)\\ 1001_2 = 9_{10} \\ 

Byte

a hard definition of 8 bits (i.e. its alway 8 bits long, unlike integers which are a general term of size n bits)
e.g. 10011101

Bytes can represent numbers, character, parts of instructions for a machine

a word is a machine-specific group of bytes
can be 4 bytes for 32-bit architecture, or 8 bytes for 64-bit architecture
Words are often expressed in hexadecimal notation to compact and more easily interpret (see conversion table from decimal to binary to hexa)

Integer

a loose definition of n number of bits
It’s typically seen as 32 bits, but certain programs, computers, languages, etc can define integers of any bit length

Leave a comment