mathexp.c

Uploaded: 25 Nov, 2008
Previous uploads by this submitter: 0

Author: Igor van den Hoven

Downloads: 59

64 bit integer arithmetic expression interpreter by Igor van den Hoven.

No restrictions on use.

Operator        Priority     Function
————————————————
! 0 logical not
~ 0 bitwise not
* 1 integer multiply
/ 1 integer divide
% 1 integer modulo
d 1 integer random dice roll
+ 2 integer addition
- 2 integer subtraction
<< 3 bitwise shift
>> 3 bitwise shift
> 4 logical greater than
>= 4 logical greater than or equal
< 4 logical less than
<= 4 logical less than or equal
== 5 logical equal (can use wildcards)
!= 5 logical not equal (can use wildcards)
& 6 bitwise and
^ 7 bitwise xor
| 8 bitwise or
&& 9 logical and
^^ 10 logical xor
|| 11 logical or

Parentheses work as expected, strings must be enclosed in quotes and
are evaluated with strcmp.

Example: mathexp("(1+2) * 3 << 4"); would return "144".