lua-users home
lua-l archive

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

Rene Rebe wrote:
> Can you elaborate what is so particularly wrong with the
> work-in-process lua-5.2 implementation?

I could. But the page on BitOp semantics explains it all.

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

Passing fractional numbers to a bit function is UNDEFINED. Look up
the meaning of UNDEFINED in the computer literature, if necessary.

And funny enough, Lua 5.2 on x86 has the exact same behavior you
complain about! :-)

Next time better check the facts for your straw-man arguments.

> I expect a bitlib to truncate for sanity and compatibly. Like in C:
>   double d = 1000.9;
>   printf("%d\n", (int)d);
> 1000

You actually write C code that mixes doubles and bit operations?!?
Please come up with a more realistic argument.

> 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.

Ah, I see. So you didn't read the page on semantics. Nor have you
understood the rationale for the implementation. And obviously the
platforms *you* care about must be the only platforms everyone
should care about? Fail.

A plain cast is slower on x86 and roughly the same speed on other
platforms. But it doesn't matter since a plain cast has the wrong
semantics, anyway.

Hint: (uint32_t)-1.0 is undefined, just like (int32_t)4294967295.0.