From 39fd5bb9b04a6a7633ddf4aa838e4909a7a0abc8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 28 Nov 1997 10:39:22 -0200 Subject: details --- lmathlib.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lmathlib.c') diff --git a/lmathlib.c b/lmathlib.c index 1a96df20..cd28b1a1 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.4 1997/11/04 15:27:53 roberto Exp roberto $ +** $Id: lmathlib.c,v 1.5 1997/11/19 18:16:33 roberto Exp roberto $ ** Lua standard mathematical library ** See Copyright Notice in lua.h */ @@ -13,7 +13,7 @@ #include "lualib.h" #ifndef PI -#define PI 3.14159265358979323846 +#define PI ((double)3.14159265358979323846) #endif @@ -24,13 +24,13 @@ static double torad (void) { - char *s = lua_getstring(lua_getglobal("_TRIGMODE")); + char *s = luaL_opt_string(2, "d"); switch (*s) { case 'd' : return PI/180.0; - case 'r' : return 1.0; + case 'r' : return (double)1.0; case 'g' : return PI/50.0; default: - luaL_verror("invalid _TRIGMODE (`%.50s')", s); + luaL_arg_check(0, 2, "invalid mode"); return 0; /* to avoid warnings */ } } @@ -120,12 +120,12 @@ static void math_exp (void) static void math_deg (void) { - lua_pushnumber(luaL_check_number(1)*180./PI); + lua_pushnumber(luaL_check_number(1)*(180.0/PI)); } static void math_rad (void) { - lua_pushnumber(luaL_check_number(1)/180.*PI); + lua_pushnumber(luaL_check_number(1)*(PI/180.0)); } -- cgit v1.2.3-55-g6feb