Close
    Search Search

    Binary coding

    Binary coding

    Presentation of the binary

    Towards the end of the 30s, Claude Shannon demonstrated that using "contactors" (switches) closed for "true" and open for "false" it was possible to perform logical operations by associating the number 1 for " true” and 0 for “false”.



    This information coding is called binary basis. It is with this coding that computers work. It consists of using two states (represented by the numbers 0 and 1) to encode the information.

    Man has been calculating since 2000 BC with 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), we then speak of a decimal base (or base 10). However, in older civilizations or for certain current applications, other calculation bases have and are still used:

    • sexagesimal base (60), used by the Sumerians. This base is also used in the current time system, for minutes and seconds;
    • vicesimal base (20), used by the Maya;
    • duodecimal base (12), used by the Anglo-Saxons in their monetary system until 1960: one “pound” represented twenty “shillings” and one “shilling” represented twelve “pences”. The current time system also works on twelve hours (in particular in the Anglo-Saxon notation);
    • quinary base (5), used by the Mayas;
    • binary base (2), used by all digital technologies.

    Our video

    Uploading your "FAQ: Binary Coding" video

    Bit

    The term bit (b with a lower case in the notations) means " binary digit », that is to say 0 or 1 in binary numbering. It is the smallest unit of information that can be manipulated by a digital machine. It is possible to physically represent this binary information:



    • by an electric, magnetic or light signal, which, beyond a certain threshold, corresponds to the value 1;
    • by geometric asperities in a surface;
    • thanks to bistables, i.e. electronic components which have two states of equilibrium (one corresponds to state 1, the other to 0).

    With one bit it is thus possible to obtain two states: either 1 or 0. Thanks to 2 bits, it is possible to obtain four different states (2*2):

    0 0
    0 1
    1 0
    1 1

    With 3 bits, it is possible to obtain eight different states (2*2*2):

    3-bit binary value Decimal value
    000 0
    001 1
    010 2
    011 3
    100 4
    101 5
    110 6
    111 7

    For a group of n bits, it is possible to represent 2^n values.

    Bit weight

    In a binary number, the value of a bit, called weight, depends on the position of the bit starting from the right. Like tens, hundreds and thousands for a decimal number, the weight of a bit increases by a power of two going from right to left as shown in the following table:



    Binary number 1 1 1 1 1 1 1 1
    Weight 2 ^ 7 = 128 2 ^ 6 = 64 2 ^ 5 = 32 2 ^ 4 = 16 2 ^ 3 = 8 2 ^ 2 = 4 2 ^ 1 = 2 2 ^ 0 = 1

    Conversions

    To convert a binary word into a decimal number, simply multiply the value of each bit by its weight, then add each result. Thus, the binary word 0101 is worth in decimal:

    2^3x0 + 2^2x1 + 2^1x0 + 2^0x1
    = 8x0 + 4x1 + 2x0 + 1x1
    = 5

    Byte

    L'byte (in English byte or B with a capital letter in the notations) is an information unit made up of 8 bits. It allows for example to store a character, such as a letter or a number.

    This grouping of numbers by series of 8 allows greater readability, just as we appreciate, in decimal base, to group the numbers by three to be able to distinguish the thousands. The number “1” is for example more readable than “256”.


    A unit of information consisting of 16 bits is usually called against (in English word).

    A unit of information 32 bits in length is called double word (in English double word, hence the name dword).

    For a byte, the smallest number is 0 (represented by eight zeros 00000000), and the largest is 255 (represented by eight "one" digits 11111111), which represents 256 different possible values.


    2^7 =128 2^6 =64 2^5 =32 2^4 =16 2^3 =8 2^2 =4 2^1 =2 2^0 =1
    0 0 0 0 0 0 0 0
    1 1 1 1 1 1 1 1

    KiloBytes, MegaBytes

    For a long time, computer science was distinguished by the use of different values ​​for the units of the international system. So many computer scientists learned that 1 kilobyte was worth 1024 bytes. However, since December 1998, the international organization IEC has ruled on the question (http://physics.nist.gov/cuu/Units/binary.html). Here are the standard units:

    • One kilobyte (kb or kB) = 1000 bytes
    • One Megabyte (MB or MB) = 1000 KB = 1 bytes
    • One Gigabyte (GB or GB) = 1000 MB = 1 bytes
    • One Terabyte (To) = 1000 GB = 1 bytes
    Binary coding Warning ! Many software (sometimes even some operating systems) still use the pre-1998 notation for which:
    • One kilobyte (KB) = 2^10 bytes = 1024 bytes
    • One Megabyte (MB) = 2^20 bytes = 1024 KB = 1 bytes
    • One Gigabyte (GB) = 2^30 bytes = 1024 MB = 1 bytes
    • One Terabyte (To) = 2 ^ 40 bytes = 1024 GB = 1 099 511 627 bytes

    The IEC has also defined binary kilo (kibi), binary mega (Mébi), binary giga (Gibi), binary tera (Tebi).
    Here are their definitions:

    • A kibibyte (kiB or kiB) is 2^10 = 1024 bytes
    • A Mebibyte (MiB or MiB) is 2^20 = 1 bytes
    • A Gibibyte (Gio or GiB) is 2^30 = 1 bytes
    • A Tebibyte (Tio or TiB) is 2^40 = 1 bytes

    It is also useful to note that the international community as a whole preferentially uses the name "byte" rather than the purely French-speaking term "octet". This gives the following notations for kilobyte, megabyte, gigabyte and terabyte:

    kB, MB, GB, TB

    Binary coding Note the use of a capital B to differentiate Byte and bit.

    Here is a screenshot of the Internet Explorer software, internet browser, showing the use of this notation:

    Binary coding

    Binary operations

    Simple arithmetic operations such as addition, subtraction and multiplication are easy to perform in binary.

    Binary addition

    Addition in binary is done with the same rules as in decimal:
    We start adding the least significant bits (the bits on the right) then we have carries when the sum of two bits of the same weight exceeds the value of the largest unit (in the case of binary: 1), this retained is transferred to the next most significant bit...

    For example:

    0 1 1 0 1
    + 0 1 1 1 0
    - - - - - -
    1 1 0 1 1

    Binary multiplication

    The multiplication table in binary is very simple:

    • 0x0 = 0
    • 0x1 = 0
    • 1x0 = 0
    • 1x1 = 1

    The multiplication is done by forming a partial product for each digit of the multiplier (only the non-zero bits will give a non-zero result). When the multiplier bit is zero, the partial product is zero, when it is one, the partial product consists of the multiplicand shifted by the number of positions equal to the weight of the multiplier bit.

    For example:

    0 1 0 1 multiplicande
    x 0 0 1 0 multiplier
    - - - - - -
    0 0 0 0
    0 1 0 1
    0 0 0 0
    - - - - - -
    0 1 0 1 0
    add a comment of Binary coding
    Comment sent successfully! We will review it in the next few hours.