[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua with ints and floats
- From: "Mauro Vezzosi"<mvezzosi@...>
- Date: Wed, 12 Jul 2000 08:57:50 +0200
Hi
> ... 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))));
> }
ldexp() don't adds its second argument but sets it as the exponent, so
you must add it manually to the exponent of the first argument.
And ldexp() doesn't resolve the problem of the fractional part and the
overflow of a real integer type (I mean that you should check if the
result is bigger than 2^16 or 2^32).
Just a curiosity: why ldexp() and frexp() are in the Lua math library ?
Are they so much used ? Isn't it more useful modf() which breaks down a
double value into fractional and integer parts ?
Bye
Mauro