62 lines
1.7 KiB
Markdown
62 lines
1.7 KiB
Markdown
# Calculator Program for Multi-Base Arithmetic
|
||
|
||
## How to Use the Calculator
|
||
|
||
### Initial Setup
|
||
- On power-up, the calculator starts in **DECIMAL mode**
|
||
- LCD shows: `Mode: DEC` on line 1, `Inp: 0` on line 2
|
||
- 7-segment displays the last digit of your input
|
||
|
||
### Basic Operations
|
||
|
||
1. **Entering Numbers**
|
||
- Press keys 0-9 for decimal digits
|
||
- In HEX mode, you can also use A-F (keys 10-15)
|
||
- In OCT mode, only 0-7 are valid
|
||
- In BIN mode, only 0-1 are valid
|
||
- Invalid digits for the current mode are ignored
|
||
|
||
2. **Changing Base Mode**
|
||
- Press **Key A (10)** to cycle through bases
|
||
- Order: BIN → OCT → DEC → HEX → BIN...
|
||
- Current mode displays on LCD top line
|
||
|
||
3. **Performing Calculations**
|
||
- Enter first number
|
||
- Press operation key:
|
||
- **Key B (11)**: Addition
|
||
- **Key D (13)**: Subtraction
|
||
- **Key E (14)**: Multiplication
|
||
- Enter second number
|
||
- Press **Key F (15)** for equals/result
|
||
|
||
4. **Clearing**
|
||
- Press **Key C (12)** to clear all (input, stored number, operation)
|
||
|
||
### Example Usage
|
||
|
||
**Example 1: Add 5 + 3 in Decimal**
|
||
```
|
||
Press: 5 → B → 3 → F
|
||
Display: Res: 8
|
||
```
|
||
|
||
**Example 2: Multiply 1010 × 11 in Binary**
|
||
```
|
||
Press: A (change to BIN mode)
|
||
Press: 1 → 0 → 1 → 0 → E → 1 → 1 → F
|
||
Display: Res: 11110 (30 in decimal)
|
||
```
|
||
|
||
**Example 3: Subtract F - A in Hexadecimal**
|
||
```
|
||
Press: A (cycle to HEX mode if not already)
|
||
Press: F → D → A (10) → F
|
||
Display: Res: 5
|
||
```
|
||
|
||
### Tips
|
||
- The 7-segment always shows the last hex digit of your current input
|
||
- Results stay in the current base mode
|
||
- If result exceeds display capacity, only visible portion shows
|
||
- After equals, the result becomes the new input for next operation
|