Question: Create a new file called bitmath.cpp . In this file, write a program that asks the user for an operation, collects its arguments ( which
Create a new file called bitmath.cpp In this file, write a program that asks the user for an operation, collects its arguments which are unsigned ints then computes the result and prints all the numbers in binary, hexadecimal, and decimal.
wendy@neverland lab$ bitmath
Operation:
add
First operand:
Second operand:
bx
bx
bx
You'll need to support four operations:
see This operation takes one operand, and simply prints it example below
add This operation takes two operands, prints both operands, then prints the result of adding the two operands together.
sub This operation behaves the same as add, but performs subtraction.
mul This operation behaves the same as add, but performs multiplication.
Sounds easy? There's a catch: You may not use any of the standard arithmetic operators. The characters and may not appear anywhere in your program, and you can only use functions from the iostream, iomanip, and string headers. Implement your own arithmetic functions using the bitwise operators: ~ & and comparison operators are allowed as well All of the inputs are unsigned ints bit unsigned integers and the output should be exactly the same as if you had used the and operators on these unsigned ints.
When printing, print leading zeros on your binary and hexadecimal numbers these should always have and digits, respectively Print two spaces between each representation of a number. The decimal representation should be leftaligned.
wendy@neverland lab$ bitmath
Operation:
see
First operand:
bxe
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
