Родитель
9abe39dd98
Сommit
8b19c6bfbf
@ -0,0 +1,34 @@
|
||||
#include "calc_bits.h"
|
||||
#include "lab04.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
uint16_t perform_bitwise_operation(uint16_t operand1, char operation, uint16_t operand2) {
|
||||
uint16_t result;
|
||||
|
||||
switch (operation) {
|
||||
case '&':
|
||||
result = operand1 & operand2;
|
||||
break;
|
||||
case '|':
|
||||
result = operand1 | operand2;
|
||||
break;
|
||||
case '^':
|
||||
result = operand1 ^ operand2;
|
||||
break;
|
||||
default:
|
||||
std::cerr << "Invalid operator. Please use '&', '|', or '^'." << std::endl;
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void print_calculation(uint16_t result) {
|
||||
std::cout << "Result in Hex: ";
|
||||
print_in_hex(result);
|
||||
std::cout << "\nResult in Binary: ";
|
||||
print_in_binary(result);
|
||||
std::cout << std::endl;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
#ifndef CALC_BITS_H_INCLUDED
|
||||
#define CALC_BITS_H_INCLUDED
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CALC_BITS_H_INCLUDED
|
Загрузка…
Ссылка в новой задаче