What is Computer Code ?
A set of symbols for representing something. For example, most computers use ASCII codes to represent characters.
Or We Can say that a written computer instructions. The term code is somewhat colloquial. For example, a programmer might say: "I wrote a lot of code this morning" or "There's one piece of code that doesn't work."
Code can appear in a variety of forms. The code that a programmer writes is called source code. After it has been compiled, it is called object code. Code that is ready to run is called executable code or machine code.
Data Types :
Knowing Data type here is essential to understand further computer codes type , We have following data types here :
Numeric Data: consists of only numbers 0, 1, 2, …, 9
Alphabetic Data:consists of only the letters A, B, C, …, Z, in both uppercase and lowercase, and blank character.
Alphanumeric Data: It a is a string of symbols where a symbol may be one of the letters A, B, C, …, Z, in either uppercase or lowercase, or one of the digits 0, 1, 2, …, 9, or a special character, such as + - * / , . ( ) = etc.
Types Of Computer Codes :-
Computer codes are used for internal representation of data in computers.
As computers use binary numbers for internal data representation, computer codes use binary coding schemes .
In binary coding, every symbol that appears in the data is represented by a group of bits.
The group of bits used to represent a symbol is called a byte.
As most modern coding schemes use 8 bits to represent a symbol, the term byte is often used to mean a group of 8 bits.
Commonly used computer codes are BCD, EBCDIC, ASCII,Gray Code , Excess-3 Code etc
1) BCD (Binary-Coded Decimal) code :-
- BCD stands for Binary Coded Decimal.It is one of the early computer codes.
- It uses 6 bits to represent a symbol
- Four-bit code that represents one of the ten decimal digits from 0 to 9.
- Example - (37)10 is represented as 0011 0111 using BCD code, rather than (100101)2 in straight binary code.
- Thus BCD code requires more bits than straight binary code.
- Still it is suitable for input and output operations in digital systems.
- It can represent 64 (2^6) different characters
Note: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE in BCD code.
2) ASCII (American Standard Code Information Interchange) code :-
- It is 7-bit or 8-bit alphanumeric code.
- 7-bit code is standard ASCII supports 127 characters.
- Standard ASCII series starts from 00h to 7Fh, where 00h-1Fh are used as control characters and 20h-7Fh as graphics symbols.
- 8-bit code is extended ASCII supports 256 symbols where special graphics and math's symbols are added.
- Extended ASCII series starts from 80h to FFh.
3) EBCDIC (Extended Binary Coded Decimal Interchange Code) code:-
- EBCDIC stands for Extended Binary Coded Decimal Interchange Code
- 8-bit alphanumeric code developed by IBM, supports 256 symbols.
- It uses 8 bits to represent a symbol
- It can represent 256 (2^8 ) different characters
- It was mainly used in IBM mainframe computers.
4) Zoned Decimal Numbers:-
These numbers are used to represent numeric values (positive,negative m,or unsigned ) in EBCDIC.
- A Sign indicator (c for plus, D for minus and F for unsigned) is used in the zone position of the right most digit.
- Zone for all other digits remain as F, the zone value for numeric characters in EBCDIC . In zoned format there is only one digit per byte.
Examples:-
Numeric Value EBCDIC Sign Indicator
345 F3F4F5 F for unsigned
+345 F3F4C5 C for positive
-345 F3F4D5 D for negative
5) Packed Decimal Numbers:-
PDN are formed from zoned decimal numbers in the following manner:
Step 1: The zone half and the digit half of the rightmost byte are reversed.
Step 2: All remaining zones are dropped out.
- Packed Decimal format requires fewer number of bytes than zoned decimal format for representing a number.
- Numbers represented in packed decimal format can be used for arithmetic operations.
Examples: Conversion of Zoned Decimal Numbers TO PDN
Numeric Value EBCDIC Sign Indicator
345 F3F4F5 345F
+345 F3F4C5 345C
-345 F3F4D5 345F
3456 F3F4F5F6 3456F
6) Gray code:-
- Differs from leading and following number by a single bit.
- Gray code for 2 is 0011 and for 3 is 0010.
- No weights are assigned to the bit positions.
- Extensively used in shaft encoders.
7) Excess-3 code:-
- 4-bit code is obtained by adding binary 0011 to the natural BCD code of the digit.
- Example - decimal 2 is coded as 0010 + 0011 = 0101 as Excess-3 code.
- It not weighted code.
- Its self-complimenting code, means 1's complement of the coded number yields 9's complement of the number itself.
- Used in digital system for performing subtraction operations.
UNICODE :
This is one of a kind of computer code , some of it features are discussed below :
Why Unicode?
- No single encoding system supports all languages
- Different encoding systems conflict
Unicode features:
- Provides a consistent way of encoding multilingual plain text
- Defines codes for characters used in all major languages of the world
- Defines codes for special characters, mathematical symbols, technical symbols, and diacritics
Unicode features (continued):
- Capacity to encode as many as a million characters
- Assigns each character a unique numeric value and name
- Reserves a part of the code space for private use
- Affords simplicity and consistency of ASCII, even corresponding characters have same code
- Specifies an algorithm for the presentation of text with bi-directional behaviour.
Encoding Forms
UTF-8, UTF-16, UTF-32