binary code

from Wikipedia, the free encyclopedia
The word "Wikipedia" (binary representation of the ASCII code)

A binary code is a code in which information is represented by sequences of two different symbols (for example 1/0 or true / false ). The basis of this system the number 2. The term derives from the Latin prefix bi on what the meaning of two or twice does.

Due to their simplicity, binary codes usually form the basis for processing digital information and are therefore often mentioned in connection with their processing; “Computers work with this code”. Many of the binary code types originated in the field of information technology and are used there; The term “binary code” is also used in computer parlance as a synonym for machine code , machine program or machine language.

Binary codes are technically very easy to map and process, e.g. B. through voltages: voltage is present → corresponds to 1 or logically true, voltage is not applied → corresponds to 0 or logically false. This smallest information unit from 1/0 or true / false is also referred to as a bit in computer science . More complex, higher-value information can be mapped through logical links using Boolean algebra or technical interconnection of several of these simple values ​​using logic gates . How higher-value information is mapped is precisely determined by the respective code. For example, in the ASCII code, the bit sequence 1000001 is "A", 1100001 is "a" - for people, however, the letters are easier to understand than the corresponding bit sequences.

The representation and interpretation of information by means of binary codes is not tied to a specific medium, but can be used anywhere where the change between two states can be generated and measured again. For example, it would even be possible (albeit nonsensical due to the low data transmission rate ) to transmit information in binary form with smoke signals (long smoking → logical 1, short smoking logical 0).

application

A clock that uses the dual code to show the time 3:25

As Claude Shannon proved in the late 1930s, switch states (like 0 or 1) make it possible to perform logical operations. Such binary codes can be mapped in technology using electronic or electromagnetic signals. The information stored in this way can be processed using complex algorithms that are implemented on integrated circuits such as those used in the processors of a wide variety of computers .

Numerical values

Binary codes can be used to represent whole numbers with a range of values ​​from 0 to n depending on the number of bits used. The basis is the dual system . Other types of numbers can also be represented with their own conventions, e.g. B. Floating point numbers ( IEEE 754 ), negative values ( two's complement ). Also texts and special characters are represented with binary code, in which case each character of a predetermined bit combination corresponds to the code whose elements are each in binary code.

Protection against transmission errors

When transmitting data, special codes are often used through which transmission errors are recognized and U. can even be corrected . These codes have a higher redundancy , so they use more bits than would be necessary to represent the information to be transmitted.

Code conversion

Different code systems are generally used to transport, process or display data. For this purpose, the existing data is converted into another code, usually automatically as part of the processing . So z. B. numerical data stored on punch cards (in a 1-out-of-n code) were converted into the EBCDIC code for processing in the computer during the reading process ; Amount fields saved as binary numbers are converted into a character code such as ASCII for display (for example in an invoice form or account statement); When printing, the printer driver or the printer itself converts the information to be printed into a printer-specific code. So-called character set tables , also known as “code pages”, can be used to convert codes .

Recognition / identification of binary codes

Although the bit pattern of stored data suggests the use of a certain code from a purely visual point of view, it is usually not possible to clearly identify the code. In general, the data does not contain any explicit information about the code according to which it is stored. Rather, when data is accessed or processed, its code (format) must be 'implicitly known'. Examples:

  • Machine code of a computer program : It exists as a long sequence of bits. These bits are e.g. B. to ASCII texts, fixed or floating point numbers, address information (each with individual length) and to machine commands 'bundled' and appear to be without structure in the main memory or in program libraries. The instructions / declarations described in the source text alone determine the format of these code parts and thus also the code. In accordance with these specifications, the programmer uses commands that,generatedas machine commands by the translator , match the defined data types and codes.
  • The same applies to files stored on data carriers : They have to be processed with suitable programs, e.g. B. with programs for spreadsheets, word processing, graphic display etc. (for which the file extensions are an aid in some operating systems ) - and / or he has to convert the data accordingly before processing. Without this adaptation, the data cannot be processed, or e.g. B. a normal text editor shows other than in ASCII coded data as a confused 'data salad'.

Different binary codes can be used in a database or data record , depending on its structure. When determining the data structure, the sequence of data fields and their format are defined ( declared ). This results in the code to be used for each field. Example: 'Record length' field = dual code 2Byte; Record type = ASCII 2 bytes, valid-from date = hex code (YYYYMMDD) 4 bytes; Amount = fixed point number 2 dec digits 16 bytes.

Examples

Classification options

Binary codes are definitions according to which a certain amount of bits is linked in order to be able to represent defined higher-value (than just dual yes-no information). The numerous variants of binary codes can be classified according to different criteria :

  • Existence form of the binary code elements (with examples):
  • Related to it: Type of processing of the code: manually without tools, mechanically, electronically
  • Type of more significant information: Codes for fixed point numbers, floating point numbers, alphanumeric characters
  • Number of bits combined in the code to form more significant information: BCD code = 4 (for numbers from 0 to 9), Hex code = 4 (for values ​​from 0 to F, numerically corresponds to 0 to 15), ASCII = 7, EBCDIC = 8th
  • Fixed or variable structure of the code: fixed for most character codes, variable e.g. B. JPG photos or machine code
  • Use of check bits in the code: No, Yes (e.g. with Gray code )

Code samples

Binary code: Significance / significance of set bits depending on the code
Dual code

The dual code is the oldest and most frequently used binary code, which can map whole numbers in the dual system . It was already described at the beginning of the 18th century. Using the dual code, for example, you can use the ten fingers of both hands to represent any whole decimal number from 0 to 1023 (   ). The code defines how many bits are used to represent numbers, common examples are: 1 byte (= 8 bits), 2, 4 or 8 bytes.

BCD code

In the BCD code , the digits 0 to 9 are encoded in four bits. The numbers from 0000 to 1001 can arise. The BCD code is also known as the 8-4-2-1 code.

EBCDIC code

The EBCDIC code developed by IBM is an 8-bit character encoding based on the older BCD code and with the i. Upper and lower case letters, special characters and the digits 0 to 9 are coded. EBCDIC is used almost exclusively on mainframes .

ASCII code

The American Standard Code for Information Interchange encodes all characters, including special English characters, in seven bits. A total of 128 (  ) different characters can be coded with the ASCII code  . In internal computer processing that is geared to the byte storage unit, the unused bit is usually assigned '0'.

Machine code

The code that can be executed directly by computer processors is specified in the instruction set of individual processor types and always contains an opcode and, if necessary, other information required for executing the instruction, such as addresses, literals, etc. in an exactly defined structure, e.g. B. Opcode 8 bits, address information 16 bytes, register information 4 bits.

Excess code

The excess code can also be used to convert signed numbers into binary code. This mainly shifts the range of values.

Stibitz code

The Stibitz code is a complementary BCD code, sometimes it is also called the excess 3 code. It also enables the coding of the decimal numbers from 0 to 9.

Aiken code

The Aiken code is also a complementary BCD code. It assigns 4 bits to all decimal digits. It differs from the BCD code only in the weighting of the individual bits.

1-out-of-n code

The 1-out-of-n code , also known as the 1-out-of-10 code, encodes a decimal number in n bits, of which only one bit can ever be 1. The checksum of the coded number always results in 1. However, this coding is not very efficient, since theoretically up to different numbers can be coded with n bits . An example of the use of this code is the punch card , where the hole positions 0 to 9 were used alternatively for purely numerical data.

Gray code

The Gray code is a continuous or one-step code. Its specialty is that neighboring values ​​differ by only one bit. The advantage is that small inaccuracies when reading out do not lead directly to incorrect information.

See also

Individual evidence

  1. binary code. itwissen.info, accessed on November 19, 2012 .
  2. Prefix "bi". Duden, accessed on November 19, 2012 .
  3. a b Presentation of the binary system. kioskea.net, accessed March 1, 2013 .
  4. get-the-solution
  5. Binary codes and code converters. oszkim.de, accessed on November 19, 2012 .
  6. Graycode. (PDF; 13 kB) Accessed November 19, 2012 .