changeset 7:089efc170bb0

Added operations log and exp since I have the code for them already...
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sun, 06 Mar 2011 01:55:09 -0500
parents 8676cf44c307
children 25b2b501a5fa
files include/operations.h src/operations.c
diffstat 2 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 <std.h>
 #include <stack.h>
 
-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
--- 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 <stack.h>
 #include <math.h>
 
-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));
+}