In computer organization, data formats refer to the way data is stored, represented, and interpreted by the computer. Data in a computer is represented in binary (0s and 1s), but the way these binary values are grouped or structured can vary depending on the type of data. Let’s break down the common data formats used in computers:
1. Binary Format
- What it is: Binary is the most basic data format. It uses only two digits: 0 and 1.
- How it's used: Everything in a computer, from text to numbers to images, is eventually converted into binary data (0s and 1s). Computers use binary because it aligns with their electrical system (ON and OFF states, or HIGH and LOW voltages).
- Example: The decimal number 5 is represented in binary as
101.
2. Decimal Format
- What it is: Decimal is the number system we use in everyday life, consisting of 10 digits (0-9).
- How it's used: While computers internally use binary, decimal numbers are often used for user input/output and display.
- Example: The number "13" in decimal is just "13".
3. Hexadecimal (Base 16) Format
- What it is: Hexadecimal is a base-16 number system. It uses 16 symbols: 0-9 and A-F (where A = 10, B = 11, C = 12, etc.).
- How it's used: Hexadecimal is often used in programming and computer systems because it’s a compact way to represent binary numbers. Every two hexadecimal digits represent a byte (8 bits), so it’s easier to read than long strings of binary digits.
- Example: The binary number
1111 1111 is represented as FF in hexadecimal.
4. Character Representation
-
What it is: This refers to the way characters (letters, numbers, symbols) are stored as binary values.
-
How it's used: There are encoding systems that map characters to binary values. The most common encoding systems are ASCII and Unicode.
-
ASCII (American Standard Code for Information Interchange):
- It represents characters (letters, digits, punctuation) as 7-bit or 8-bit binary numbers.
- Example: The letter 'A' in ASCII is
01000001.
-
Unicode:
- Unicode is a more comprehensive system that can represent characters from many different languages and symbols. It uses 16 bits or more, allowing for a larger character set.
5. Integer Format
- What it is: Integers are whole numbers (positive or negative) stored in binary.
- How it's used: In computers, integers are usually represented using two common methods:
- Signed Integer Representation: Indicates whether the number is positive or negative. This can be done using Two's complement or Sign-magnitude representations.
- Unsigned Integer Representation: This represents only positive numbers (0 or greater).
- Example:
- Signed Integer (using 8 bits): The number
-5 in two’s complement is 11111011.
- Unsigned Integer (using 8 bits): The number
5 is represented as 00000101.
6. Floating-Point Format
- What it is: Floating-point format is used to represent real numbers (numbers with decimal points).
- How it's used: This format allows the computer to store numbers with large ranges, both very small and very large numbers.
- It works by breaking the number into three parts: sign bit, exponent, and fraction (or mantissa).
- IEEE 754 Standard is the most widely used standard for floating-point representation.
- Example: The number
3.14 in floating-point representation would be split into its binary equivalent, with separate parts for the sign, exponent, and mantissa.
7. Fixed-Point Format
- What it is: In fixed-point format, numbers are represented as integers, but the decimal point is fixed at a particular position.
- How it's used: This format is often used in embedded systems or hardware applications where floating-point operations are expensive.
- Example: The number
3.14 can be represented as 314 (by shifting the decimal point) and treating it as an integer.
8. BCD (Binary Coded Decimal)
- What it is: BCD is a way of encoding decimal numbers where each digit of a decimal number is represented by a 4-bit binary code.
- How it's used: BCD is used in some systems where you need to store and process numbers in decimal format, but still want to use binary for easier computation.
- Example: The decimal number
45 in BCD would be represented as 01000101.
9. String Format
- What it is: A string is a sequence of characters (like words or sentences).
- How it's used: In assembly language and computer programming, strings are stored as an array of characters, where each character is represented by a binary value (using ASCII, Unicode, etc.).
- Example: The string "Hello" is stored as
01001000 01100101 01101100 01101100 01101111.
Summary of Key Data Formats:
| Data Format |
Description |
Example |
| Binary |
Represents data using 0s and 1s. |
101 |
| Decimal |
The regular number system we use (base 10). |
13 |
| Hexadecimal |
Base 16 number system used for compact representation. |
FF (binary 1111 1111) |
| ASCII/Unicode |
Representation of characters (letters, digits, symbols). |
ASCII for 'A' = 01000001 |
| Integer |
Whole numbers represented in binary (signed/unsigned). |
5 (binary 00000101) |
| Floating-Point |
Used for real numbers (decimal values). |
3.14 (floating-point format) |
| Fixed-Point |
Decimal values with a fixed decimal point. |
314 for 3.14 (fixed-point) |
| BCD (Binary Coded Decimal) |
Decimal digits represented in binary. |
01000101 for 45 |
| String |
Sequence of characters stored as binary values. |
"Hello" stored as 01001000 01100101... |
Understanding these data formats helps in understanding how computers store, process, and manipulate data at the binary level.