lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


The funny thing.... ldexp is already in lmathlib :-))
/Erik

----- Original Message -----
From: "Adolf Mathias" <dolfi@zkm.de>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Tuesday, July 11, 2000 4:29 PM
Subject: Re: Lua with ints and floats


My two cents to the bitshift issue:

If you have access to a reasonably complete math lib (exists even for
Vicious C++ 6.0), you may use ldexp, which directly adds its second
integer argument to the IEEE FP exponent of the first double argument
and returns the result.

static void bitshiftleft(lua_State *L)
{
        lua_pushnumber((lua_Number)
(ldexp(luaL_check_number(1),(int)luaL_check_number(2))));
}

or, what probably makes more sense, make ldexp accessible.

Ciao, Dolfi

--
Adolf Mathias              EMail: dolfi at zkm dot de  Web: www.zkm.de
|||| / |< ||| ZKM Institute for Visual Media - Institut für Bildmedien
P.B. 6919 D-76049 Karlsruhe, Germany; fon +49 721-8100-1544, fax -1509