I´m trying to write a program in C++ in which I could std::cin a binary number of the type std::vector with random length and then std::cin one of the following operators:
If the operator "ˆ" is entered, it should flip the bits so that 0 is 1 and vice versa, and then output the flipped number.
If the operator "par" is entered, it should output the parity (amount of 1´s) of the entered binary number.
If the operator "&" is entered, it should let me enter a second binary number of the type std:vector with random length and then output a bitwise AND of both binary numbers.
If the operator "|" is entered, it should let me enter a second binary number and then output a bitwise OR of both binary numbers.
If the operator "con" is entered, it should let me enter a second binary number and then output the concatenation of the first entered binary number to the second one.
If the operator ":" is entered, it should let me enter a second binary number and then output the division (first number is dividend, second one is divisor).
If the operator ">" is entered, it should let me enter a second binary number, convert both binary vectors to unsigned long long int, and then output "Yes" if the first number is bigger than the second one, or "No" if the first one is smaller.
If the operator "<" is entered, it should let me enter a second binary number, convert both binary vectors to unsigned long long int, and then output "Yes" if the first number is smaller than the second one, or "No" if the first one is bigger.
If the operator "==" is entered, it should let me enter a second binary number, convert both binary vectors to unsigned long long int, and then output "Yes" if both numbers are equal, or "No" if they aren´t.
If the operator "!=" is entered, it should let me enter a second binary number, convert both binary vectors to unsigned long long int, and then output "Yes" if both numbers aren´t equal, or "No" if they are.
Unfortunately I coudn´t get this to work. If someone could help me, i would very much appreciate that. Thanks in advance.
we can't fix it without seeing it... post your code (in tags, the <> thingy on the editor).
break it down. Do just one of the tasks, like bitwise 'or' or something (or pull the one task from your code) and post that much, show us what isnt working. How long/large a number do you want to support? Are you using 2's comp negative values? Which byte order?