From e8f7057f5911f6d676d773913692914214fad2db Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Tue, 4 May 2010 18:34:47 -0400 Subject: [PATCH] specify ln to log() for natural log evaluation --- posty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/posty.c b/posty.c index cecebc6..24efb6a 100644 --- a/posty.c +++ b/posty.c @@ -189,6 +189,8 @@ int parse_mfunc(char *mfunc) { res = atan(op1); else if (strcmp(mfunc, "sqrt") == 0) res = sqrt(op1); + else if (strcmp(mfunc, "ln") == 0) + res = log(op1); if (verbose == 1) printf("%s(%.*f) = %.*f\n", mfunc, precision, op1, precision, res); @@ -204,7 +206,7 @@ int parse_expression(char *expr) { char *token; static const char *operators = "+/*-%^"; - static const char *mfuncs = "|sqrt|sin|cos|tan|asin|acos|atan|"; + static const char *mfuncs = "|ln|sqrt|sin|cos|tan|asin|acos|atan|"; static const char *constants = "|e|pi|"; double operand; char *ptr;