This is an advance calculator performing the following basic & bitwise operations:
Operation | Explanation |
---|---|
a + b | Returns summation of a and b. |
a * b | Returns multiplication of a and b. |
a - b | Returns the subtraction of b from a. |
a & b | Returns bitwise a and b. |
a | b | Returns bitwise a or b. |
xor(a, b) | Returns bitwise a xor b. |
ls(a, i) | Returns the result of a shifted i bits to the left. |
rs(a, i) | Returns the result of a shifted i bits to the right. |
lr(a, i) | Returns the result of a rotated i times to the left. |
rr(a, i) | Returns the result of a rotated i times to the right. |
not(a) | Returns bitwise complement of a. |
It takes inputs via an interpreter. It parses the input through a grammar that supports variable assignment, retriaval and expressions in parentheses. For more information refer to the project report.
To run the program simply compile advcalc.c, which will give you the interpreter mode. You can also run it on a text file via terminal (input.txt provided as an example) by the following command:
./advcalc < input.txt