This commit is contained in:
Roberto Ierusalimschy 1997-11-28 10:39:22 -02:00
parent 5482992dec
commit 39fd5bb9b0
2 changed files with 9 additions and 9 deletions

View File

@ -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 ** Lua standard mathematical library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -13,7 +13,7 @@
#include "lualib.h" #include "lualib.h"
#ifndef PI #ifndef PI
#define PI 3.14159265358979323846 #define PI ((double)3.14159265358979323846)
#endif #endif
@ -24,13 +24,13 @@
static double torad (void) static double torad (void)
{ {
char *s = lua_getstring(lua_getglobal("_TRIGMODE")); char *s = luaL_opt_string(2, "d");
switch (*s) { switch (*s) {
case 'd' : return PI/180.0; case 'd' : return PI/180.0;
case 'r' : return 1.0; case 'r' : return (double)1.0;
case 'g' : return PI/50.0; case 'g' : return PI/50.0;
default: default:
luaL_verror("invalid _TRIGMODE (`%.50s')", s); luaL_arg_check(0, 2, "invalid mode");
return 0; /* to avoid warnings */ return 0; /* to avoid warnings */
} }
} }
@ -120,12 +120,12 @@ static void math_exp (void)
static void math_deg (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) static void math_rad (void)
{ {
lua_pushnumber(luaL_check_number(1)/180.*PI); lua_pushnumber(luaL_check_number(1)*(PI/180.0));
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lobject.h,v 1.8 1997/11/03 20:45:23 roberto Exp roberto $ ** $Id: lobject.h,v 1.9 1997/11/19 17:29:23 roberto Exp roberto $
** Type definitions for Lua objects ** Type definitions for Lua objects
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -131,7 +131,7 @@ typedef struct LocVar {
#define fvalue(o) ((o)->value.f) #define fvalue(o) ((o)->value.f)
#define tfvalue(o) ((o)->value.tf) #define tfvalue(o) ((o)->value.tf)
#define protovalue(o) (&(o)->value.cl->consts[0]) #define protovalue(o) ((o)->value.cl->consts)
/* /*
** Closures ** Closures