about summary refs log tree commit diff
path: root/Src/Modules
diff options
context:
space:
mode:
authorJun T <takimoto-j@kba.biglobe.ne.jp>2013-10-27 00:41:03 +0900
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2013-10-27 00:00:56 +0100
commitef4d20ad6fde1ca519a19ad60f2c31d86f5b1d98 (patch)
treee328dcbb8127ce13408d57af693e1a386b84fb6f /Src/Modules
parent7a79f660db07283c25205af38a4a9fd8618db4d5 (diff)
downloadzsh-ef4d20ad6fde1ca519a19ad60f2c31d86f5b1d98.tar.gz
zsh-ef4d20ad6fde1ca519a19ad60f2c31d86f5b1d98.tar.xz
zsh-ef4d20ad6fde1ca519a19ad60f2c31d86f5b1d98.zip
31902: rationalise use of gamma function.
Make zsh/mathfunc consistent across systems and use tgamma() where
available
Diffstat (limited to 'Src/Modules')
-rw-r--r--Src/Modules/mathfunc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Src/Modules/mathfunc.c b/Src/Modules/mathfunc.c
index 04483b555..efadd86ff 100644
--- a/Src/Modules/mathfunc.c
+++ b/Src/Modules/mathfunc.c
@@ -340,7 +340,16 @@ math_func(char *name, int argc, mnumber *argv, int id)
       break;
 
   case MF_GAMMA:
+#ifdef HAVE_TGAMMA
+      retd = tgamma(argd);
+#else
+#ifdef HAVE_SIGNGAM
+      retd = lgamma(argd);
+      retd = signgam*exp(retd);
+#else /*XXX assume gamma(x) returns Gamma(x), not log(|Gamma(x)|) */
       retd = gamma(argd);
+#endif
+#endif
       break;
 
   case MF_HYPOT: