lua-users home
lua-l archive

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



On 09.01.2010, at 15:58, Miles Bader wrote:

Rene Rebe <rene@exactcode.de> writes:
No. But given that Lua (reasonably) defaults to double I expect to be
able to use them reasonably. And not to trap into a surprising result
in every line:

-- lua-5.2(work1)
= bit.band(0xffff / 256, 0xff)
255

There are better ways to write that, and you should use them...
expecting fractions to silently be dropped is just plain dodgy.

[e.g., = bit.band (bit.rshift (0xffff, 8), 0xff) ]

I know this and all the details. Been there, done that.

I already wrote that the concern is about least surprise and coding style. I do not consider using bit.Xshift or math.{round,ceil,floor} everywhere to be especially beautiful nor readable (reviewable, maintainable) code. This undefined, yet unexpected behaving rather leads to mistakes rather sooner than later.

-- 
  René Rebe, ExactCODE GmbH, Jaegerstr. 67, DE-10117 Berlin