Number System
Number Representation
A number can be represented by
Where is base or radix.
Let be the base, then
Common Bases
| Name | Base | Postfix |
|---|---|---|
| Binary Number | ||
| Octal Number | or | |
| Decimal Number | ||
| Hexadecimal Number |
Number Conversions
Convert to Decimal Numbers
Suppose there is a number in base , which looks like , then the formula of converting it to a decimal number is:
Convert A Decimal Number to Other Bases
Suppose there is a decimal number n, and it needs to be converted to a number based b. Then the process is:
- Calculate .
- Append to the end of result.
- Let
- Repeat steps 1 to 3 until .
Conversion Between Non-decimal Numbers
Convert a number to binary number, and then convert the binary number to the target number.
Non-numeric Data Representation
Binary Coded Decimal (BCD) Code
The range of a BCD digit is 0000B to 1001B, also decimal.
It has two types, packed BCD and unpacked BCD.
- Packed BCD stores two digits per byte, which is better for storage.
- Unpacked BCD stores one digit per byte, which is easy for computer to access data.
ASCII Code
The range of ASCII code is from to , while extended ASCII code is range from to .
Units
- Bit ( or )
- Byte (8 bits)
- Word (16 bits)
- Double word (32 bits)
Last updated on