Inputs
A valid arithmetic equation or the word QUIT (to exit the program). See the Constraints section below for a list of supported operators and syntax rules.
Outputs
The solution to the equation.
The following operations (listed in highest to lowest precedence order) are supported by the equation solver: ("a" and "b" below are operands)
Round up to nearest integer CEIL(a) (Ex. CEIL(3.2) = 4) Round down to nearest integer FLOOR(a) (Ex. FLOOR(-2.4) = -3) Involution (exponentiation) a^b (Ex. 3.0^2 = 9) Division a/b (Exs. 10/3 = 3 ; 10.0/3 = 3.333333) Multiplication a*b (Ex. 2*3 = 6) Modulo a%b (Ex. 10%3 = 1) Addition a+b (Ex. 23+1= 24) Subtraction a-b (Ex. -4--5 = 1) Bit-wise AND a&b (Ex. 3&1 = 1) Bit-wise exclusive-OR a~b (Ex. 2~3 = 1) Bit-wise OR a|b (Ex. 2|3 = 3)
Parentheses can be used to modify the order of evaluation as usual. Spaces are ignored except that they cannot appear between the unary operators CEIL and FLOOR and the operand. The solver distinguishes between integer and floating-point arithmetic (see the examples above for division). To exit the application, enter "QUIT" or "quit" as the equation.
% eqn_test_driver Input equation (QUIT to exit): 3+3 6 Input equation (QUIT to exit): (3*(CEIL(-1.3)-10)/67.0^2) -0.007351303185564715 Input equation (QUIT to exit): QUIT %