-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathALU.h
More file actions
38 lines (30 loc) · 652 Bytes
/
ALU.h
File metadata and controls
38 lines (30 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef ALU_H
#define ALU_H
#include <cstdint>
#include <iostream>
using namespace std;
class ALU {
public:
ALU() {}
uint16_t add(uint16_t a, uint16_t b) {
return a + b;
}
uint16_t multiply(uint16_t a, uint16_t b) {
return a * b;
}
uint16_t divide(uint16_t a, uint16_t b) {
if (b == 0) {
cerr << "[Error] Division by zero" << endl;
return 0;
}
return a / b;
}
uint16_t modulo(uint16_t a, uint16_t b) {
if (b == 0) {
cerr << "[Error] Modulo by zero" << endl;
return 0;
}
return a % b;
}
};
#endif