From 74719afc333a70dae37aa6014ee1bd50ec8aa895 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 27 May 1998 16:09:39 -0300 Subject: new functions "frexp" and "ldexp" --- lmathlib.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lmathlib.c') diff --git a/lmathlib.c b/lmathlib.c index ad462535..8b8babaa 100644 --- a/lmathlib.c +++ b/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.7 1997/12/09 13:35:19 roberto Exp roberto $ +** $Id: lmathlib.c,v 1.8 1997/12/26 18:36:31 roberto Exp roberto $ ** Lua standard mathematical library ** See Copyright Notice in lua.h */ @@ -115,6 +115,16 @@ static void math_rad (void) lua_pushnumber(luaL_check_number(1)*(PI/180.0)); } +static void math_frexp (void) { + int e; + lua_pushnumber(frexp(luaL_check_number(1), &e)); + lua_pushnumber(e); +} + +static void math_ldexp (void) { + lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_number(2))); +} + static void math_min (void) @@ -170,10 +180,12 @@ static struct luaL_reg mathlib[] = { {"asin", math_asin}, {"acos", math_acos}, {"atan", math_atan}, -{"atan2", math_atan2}, +{"atan2", math_atan2}, {"ceil", math_ceil}, {"floor", math_floor}, {"mod", math_mod}, +{"frexp", math_frexp}, +{"ldexp", math_ldexp}, {"sqrt", math_sqrt}, {"min", math_min}, {"max", math_max}, -- cgit v1.2.3-55-g6feb