# HG changeset patch # User Jonathan Pevarnek # Date 1299394509 18000 # Node ID 089efc170bb0a6934d3992a80c65a64e394462ef # Parent 8676cf44c307c2a576026803d4027a0c21a4b114 Added operations log and exp since I have the code for them already... diff -r 8676cf44c307 -r 089efc170bb0 include/operations.h --- a/include/operations.h Sun Mar 06 01:38:01 2011 -0500 +++ b/include/operations.h Sun Mar 06 01:55:09 2011 -0500 @@ -4,7 +4,7 @@ #include #include -enum Operation {PRINT, ADD, SUB, MULT, DIV, POW, DUP, DROP, MAXOP}; +enum Operation {PRINT, ADD, SUB, MULT, DIV, POW, DUP, DROP, LOG, EXP, MAXOP}; extern const char operationNames[MAXOP][10]; extern void (*operation[MAXOP])(struct Stack*); @@ -16,5 +16,7 @@ void op_pow(struct Stack *stack); void op_dup(struct Stack *stack); void op_drop(struct Stack *stack); +void op_log(struct Stack *stack); +void op_exp(struct Stack *stack); #endif //__OPERATIONS_H diff -r 8676cf44c307 -r 089efc170bb0 src/operations.c --- a/src/operations.c Sun Mar 06 01:38:01 2011 -0500 +++ b/src/operations.c Sun Mar 06 01:55:09 2011 -0500 @@ -3,9 +3,9 @@ #include #include -const char operationNames[MAXOP][10] = {".", "+", "-", "*", "/", "**", "dup", "drop"}; +const char operationNames[MAXOP][10] = {".", "+", "-", "*", "/", "**", "dup", "drop", "log", "exp"}; void (*operation[MAXOP])(struct Stack*) = {op_print, op_add, op_sub, op_mult, - op_div, op_pow, op_dup, op_drop}; + op_div, op_pow, op_dup, op_drop, op_log, op_exp}; void op_print(struct Stack *stack) { @@ -61,3 +61,15 @@ { pop(stack); } + +void op_log(struct Stack *stack) +{ + eltType val = pop(stack); + push(stack, math_log(val)); +} + +void op_exp(struct Stack *stack) +{ + eltType val = pop(stack); + push(stack, math_exp(val)); +}