In: Computer Science
A calculation engine is being built to set up an order-of-operations for solving equations. The priority of the operations is as follows:
1. Parentheses, Priority 1 highest
2. Exponents, Priority 2
3. Multiplication, Priority 3
4. Division, also Priority 3
5. Modulus, also Priority 3
6. Addition, Priority 4, Lowest
7. Subtraction, Also priority 4
Each of bulleted items in the list above is represented by a one-bit input wire in a control circuit system, for a total of 7 inputs. The outputs are binary integers 1 through 4.
Use combinational logic and gate logic to create a piece of control circuitry that will assign the correct 2-bit binary integer based on the system priority. The output should be the highest priority among the inputs.
Include a short, well-written description about the approach you chose. Do not include a 128-line truth table. If you use this approach, you are going about it the wrong way. Remember: Divide and Conquer!
the final set of outputs on question 4.4 would be in the form of {001,010,011,100}.
mathametical statement
=7+3*5
Interpretated 2 types
1st type 2nd type
=10*5 =7+15
=50 =22
completely unacceptable because of two different mode of operations
The order of operation must be start with
EX:
=7+34*4/2-5*6
=10*4/2-5*6
=40/2-5*6
=20-30
=-10
The simple answer is "Yes" C++ follows the standard order of precedence.we would note that in PEMDAS the E stands for "exponent" and there is no way to express that in C++ you need to make a function call to achieve it but the rest is correct. P Parathasis first. E Exponent second. MD Multiplication and Division third (have the same precedence) AS Addition and Subtraction fourth (have the same precedence) MD happen left to right AS happen left to right
5/9 * (34/.2)
it will have a hard time computing this formula due to the fact that the parentheses are at the end and not the front. Is this correct?
Wrong. The above expression is well define in maths and in C++ and has the same meaning.
(34/.2) *5/9
my formula works. Any tips, pointers, guidance is appreciated.
These are not the same expression. Multiplication and division have the same precedence and are applied left to right. You have changed the order of how these operators are applied. But you say they are supposed to be associative (i.e. order is not important). That is true. But you also have to throw in the type information. One easy thing to forget is that integer division is not what you expect (it throws away the remainder).
Version 1:
5/9 * (34/.2)
34/.2 => P1 170.0
5/9 => P2 0 // Integer division
P2 * P1 => P3 0
Version 2
(34/.2) *5/9
34/.2 => P1 170.0
P1 * 5 => P2 850.0
P2 / 9 => P3 94.4