Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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:
bxeCreate 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 int s then computes the result and prints all the numbers in binary, hexadecimal, and decimal.
wendy@neverland lab$bitmath
Operation:
add
First operand:
Second operand:
Obx
b
b
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 cdots, 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 int bit unsigned integers and the output should be exactly the same as if you had used the, and operators on these
unsigned int
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 int s then computes the result and prints all the numbers in binary, hexadecimal, and decimal.
wendy@neverland lab$bitmath
Operation:
add
First operand:
Second operand:
b ex
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: &hat and comparison operators are allowed as well All of the inputs are
unsigned int s bit unsigned integers and the output should be exactly the same as if you had used the, and operators on these
unsign
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started