summaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-09 11:50:08 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-09 11:50:08 -0200
commit80b3d28f4a9e518bf40b35f786199919180bfcd4 (patch)
treee25a410ba61883244207e25b16a853991b417ebb /lmathlib.c
parent69d97712ecfcd06aa4edb7374b262131210d0bbc (diff)
downloadlua-github-80b3d28f4a9e518bf40b35f786199919180bfcd4.tar.gz
details (mainly error messages)
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/lmathlib.c b/lmathlib.c
index cd28b1a1..13c74a0a 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmathlib.c,v 1.5 1997/11/19 18:16:33 roberto Exp roberto $
+** $Id: lmathlib.c,v 1.6 1997/11/28 12:39:22 roberto Exp roberto $
** Lua standard mathematical library
** See Copyright Notice in lua.h
*/
@@ -12,28 +12,15 @@
#include "lua.h"
#include "lualib.h"
-#ifndef PI
+#ifdef M_PI
+#define PI M_PI
+#else
#define PI ((double)3.14159265358979323846)
#endif
-
-#define FROMRAD(a) ((a)/torad())
-#define TORAD(a) ((a)*torad())
-
-
-static double torad (void)
-{
- char *s = luaL_opt_string(2, "d");
- switch (*s) {
- case 'd' : return PI/180.0;
- case 'r' : return (double)1.0;
- case 'g' : return PI/50.0;
- default:
- luaL_arg_check(0, 2, "invalid mode");
- return 0; /* to avoid warnings */
- }
-}
+#define FROMRAD(a) ((a)*(180.0/PI))
+#define TORAD(a) ((a)*(PI/180.0))
static void math_abs (void)