lua-users home
lua-l archive

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



On Jul 25, 2013, at 6:08 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

The fact that most people should not bother with this difference was
the initial motivation to put the distinction in the debug library.


Will this remain true if (when?) the bit operator library gets extended to 64 bits? So far as I understand it, values between 2^52 and 2^64 are going to be a gray area in this case, since the "same" numeric value will behave differently depending on if its held as an integer or floating point?

You do not need bit operators for that. As an example, for any x in this
gray area, (x + 1 == x) is true iff x is held as a float. My point is
that, most of the time, numbers will have the "expected" type, mainly
when they are in this gray area.

Sorry I didn't quite make myself clear. I was thinking of the case of something like this:

function mask64(x, y)
-- Insert checking code here???
return bit64.and(x,y) != 0
end

Assuming "bit64.and()" is a 64-bit aware bitwise AND function. Depending on how such a library works, won't SOMEONE (bit library or the above function) have to check if x/y are float or integer, for the gray area?

I think what I'm hearing is that (x+1 == x) is the "blessed" way to do this check going forward?

--Tim