Tedd OKANO / Mbed 2 deprecated RPN_calc__based_on_K_and_R

Dependencies:   mbed

Revision:
2:0e96f4495b43
Child:
3:4ef74510cc5b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stack.cpp	Fri Jun 26 10:16:24 2015 +0000
@@ -0,0 +1,26 @@
+#include    "mbed.h"
+#include    "calc.h"
+
+#define     MAXVAL  100
+
+int     sp  = 0;
+double  val[ MAXVAL ];
+
+void push( double f )
+{
+    if ( sp < MAXVAL )
+        val[ sp++ ] = f;
+    else
+        printf( "error: stack full, can't push %g\n", f );
+}
+
+
+double pop( void )
+{
+    if ( sp > 0 )
+        return val[ --sp ];
+    else {
+        printf( "error: stack empty\n" );
+        return 0.0;
+    }
+}