summaryrefslogtreecommitdiff
path: root/lmathlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-27 16:09:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-05-27 16:09:39 -0300
commit74719afc333a70dae37aa6014ee1bd50ec8aa895 (patch)
treec523b3b79a5fb9f9bf7ef9695ba78fb78988d724 /lmathlib.c
parent7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6 (diff)
downloadlua-74719afc333a70dae37aa6014ee1bd50ec8aa895.tar.gz
lua-74719afc333a70dae37aa6014ee1bd50ec8aa895.tar.bz2
lua-74719afc333a70dae37aa6014ee1bd50ec8aa895.zip
new functions "frexp" and "ldexp"
Diffstat (limited to 'lmathlib.c')
-rw-r--r--lmathlib.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lmathlib.c b/lmathlib.c
index ad462535..8b8babaa 100644
--- a/lmathlib.c
+++ b/lmathlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lmathlib.c,v 1.7 1997/12/09 13:35:19 roberto Exp roberto $ 2** $Id: lmathlib.c,v 1.8 1997/12/26 18:36:31 roberto Exp roberto $
3** Lua standard mathematical library 3** Lua standard mathematical library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -115,6 +115,16 @@ static void math_rad (void)
115 lua_pushnumber(luaL_check_number(1)*(PI/180.0)); 115 lua_pushnumber(luaL_check_number(1)*(PI/180.0));
116} 116}
117 117
118static void math_frexp (void) {
119 int e;
120 lua_pushnumber(frexp(luaL_check_number(1), &e));
121 lua_pushnumber(e);
122}
123
124static void math_ldexp (void) {
125 lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_number(2)));
126}
127
118 128
119 129
120static void math_min (void) 130static void math_min (void)
@@ -170,10 +180,12 @@ static struct luaL_reg mathlib[] = {
170{"asin", math_asin}, 180{"asin", math_asin},
171{"acos", math_acos}, 181{"acos", math_acos},
172{"atan", math_atan}, 182{"atan", math_atan},
173{"atan2", math_atan2}, 183{"atan2", math_atan2},
174{"ceil", math_ceil}, 184{"ceil", math_ceil},
175{"floor", math_floor}, 185{"floor", math_floor},
176{"mod", math_mod}, 186{"mod", math_mod},
187{"frexp", math_frexp},
188{"ldexp", math_ldexp},
177{"sqrt", math_sqrt}, 189{"sqrt", math_sqrt},
178{"min", math_min}, 190{"min", math_min},
179{"max", math_max}, 191{"max", math_max},