aboutsummaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-18 14:47:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-18 14:47:53 -0300
commit3ac595da8a21770826894a926425d66dddd8c85e (patch)
treede48f15a9a4007b98d6950bc65b274cc1ff7849c /lmathlib.c
parentea980fdeef9859c99d69b29b26695fd619a32a33 (diff)
downloadlua-3ac595da8a21770826894a926425d66dddd8c85e.tar.gz
lua-3ac595da8a21770826894a926425d66dddd8c85e.tar.bz2
lua-3ac595da8a21770826894a926425d66dddd8c85e.zip
allow "long double" precision for PI constant if needed
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lmathlib.c b/lmathlib.c
index 035dd090..bc8df46e 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.79 2010/11/18 18:38:27 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.80 2011/07/05 12:49:35 roberto Exp roberto $
3** Standard mathematical library 3** Standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -17,17 +17,17 @@
17#include "lualib.h" 17#include "lualib.h"
18 18
19 19
20#undef PI
21#define PI (3.14159265358979323846)
22#define RADIANS_PER_DEGREE (PI/180.0)
23
24
25/* macro 'l_tg' allows the addition of an 'l' or 'f' to all math operations */ 20/* macro 'l_tg' allows the addition of an 'l' or 'f' to all math operations */
26#if !defined(l_tg) 21#if !defined(l_tg)
27#define l_tg(x) (x) 22#define l_tg(x) (x)
28#endif 23#endif
29 24
30 25
26#undef PI
27#define PI (l_tg(3.1415926535897932384626433832795))
28#define RADIANS_PER_DEGREE (PI/180.0)
29
30
31 31
32static int math_abs (lua_State *L) { 32static int math_abs (lua_State *L) {
33 lua_pushnumber(L, l_tg(fabs)(luaL_checknumber(L, 1))); 33 lua_pushnumber(L, l_tg(fabs)(luaL_checknumber(L, 1)));