From 22ed7f473a5c1e1db722286f98b2457a74cc1ca7 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 Mar 2014 23:54:02 -0800 Subject: * arith.c (logten): New function. * eval.c (eval_init): logten registered as intrinsic. * lib.h (logten): Declared. * txr.1: Documented. --- ChangeLog | 10 ++++++++++ arith.c | 5 +++++ eval.c | 1 + lib.h | 1 + txr.1 | 6 +++++- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 588d2f6f..1ad8d631 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2014-03-04 Kaz Kylheku + + * arith.c (logten): New function. + + * eval.c (eval_init): logten registered as intrinsic. + + * lib.h (logten): Declared. + + * txr.1: Documented. + 2014-03-03 Kaz Kylheku * parser.l: Allowing ^ to be a quote character, and adjusting definition diff --git a/arith.c b/arith.c index f227f217..1eb9c5fb 100644 --- a/arith.c +++ b/arith.c @@ -1439,6 +1439,11 @@ val loga(val num) return flo(log(c_flo(to_float(lit("log"), num)))); } +val logten(val num) +{ + return flo(log10(c_flo(to_float(lit("log"), num)))); +} + val expo(val num) { return flo(exp(c_flo(to_float(lit("exp"), num)))); diff --git a/eval.c b/eval.c index 7936da92..51339182 100644 --- a/eval.c +++ b/eval.c @@ -3241,6 +3241,7 @@ void eval_init(void) reg_fun(intern(lit("atan"), user_package), func_n1(atang)); reg_fun(intern(lit("atan2"), user_package), func_n2(atang2)); reg_fun(intern(lit("log"), user_package), func_n1(loga)); + reg_fun(intern(lit("log10"), user_package), func_n1(logten)); reg_fun(intern(lit("exp"), user_package), func_n1(expo)); reg_fun(intern(lit("sqrt"), user_package), func_n1(sqroot)); reg_fun(intern(lit("cum-norm-dist"), user_package), func_n1(cum_norm_dist)); diff --git a/lib.h b/lib.h index cb9a9762..e62eec93 100644 --- a/lib.h +++ b/lib.h @@ -497,6 +497,7 @@ val acosi(val); val atang(val); val atang2(val, val); val loga(val); +val logten(val num); val expo(val); val logand(val, val); val logior(val, val); diff --git a/txr.1 b/txr.1 index 22f99f62..deff8d86 100644 --- a/txr.1 +++ b/txr.1 @@ -9778,13 +9778,14 @@ functions. The argument to asin and acos must be in the range -1.0 to 1.0. The atan2 function converts the rectilinear coordinates and to an angle in polar coordinates in the range [0, 2pi). -.SS Functions log, exp +.SS Functions exp, log, log10 .TP Syntax: (exp ) (log ) + (log10 ) .TP Description: @@ -9795,6 +9796,9 @@ the specified exponent. The log function calculates the base e logarithm of its argument, which must be a positive value. +The log10 function calculates the base 10 logarithm of its argument, which must +be a positive value. + Integer arguments are converted to floats. .SS Functions expt, sqrt, isqrt -- cgit v1.2.3