lua-users home
lua-l archive

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


On 09.01.2010, at 00:41, Mike Pall wrote:

> Luiz Henrique de Figueiredo wrote:
>> All feedback welcome. Thanks.
> 
> Yes, I'd like to *vehemently* protest about the included
> abomination of a bit library!
> 
> It's INCOMPATIBLE to *all* other bit libraries out there! And it
> has nonsensical system-dependent semantics, esp. wrt. the number
> type. How on earth should one write portable code that way?
> 
> Do you really want to repeat the learning curve that the lbitlib
> author and myself as the author of Lua BitOp had to go through?
> Have you read the lengthy page on portable bit operations
> semantics I wrote?
> 
> I cannot understand what stops you from just dropping in the
> latest Lua BitOp and *be done*.


Can you elaborate what is so particularly wrong with the work-in-process lua-5.2 implementation?

Actually your bitop lib has very strange rounding characteristics due to the exotic number conversion:

> return  bit.bor(1.4, 0)
1
> return  bit.bor(1.5, 0)
2
> return  bit.bor(1000.5, 0)
1000
> return  bit.bor(1000.6, 0)
1001

(above taken from a x86-64/linux system, I guess the results are the same elsewhere)

I expect a bitlib to truncate for sanity and compatibly. Like in C:

  double d = 1000.9;
  printf("%d\n", (int)d);

1000

The strange rounding of your lib made me use my own that just casts. Works on all the platforms I care about (x86, x64-64, ppc, ppc64, sparc64 and I do not see where it should fail), and is actually some 20% or so faster than your strange game that is the fiddling with the union.

-- 
  René Rebe, ExactCODE GmbH, Jaegerstr. 67, DE-10117 Berlin
  http://exactcode.com | http://t2-project.org | http://rene.rebe.name