lua-users home
lua-l archive

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


Zhu Ya Dong wrote:
> In my computer, when count > 50, this test will cause luajit crash.

Thank you for the report! Fixed in git HEAD.

> ffi.cdef[[
> typedef struct rect{float left, top, right, bottom;};
> ]]

Note that storing numbers as floats is rarely beneficial. The
actual computations are performed as doubles. So this needs extra
conversion from float to double and from double to float for every
arithmetic operation. These are rather costly.

Floats are only needed to interface to existing C code or when you
desperately need to save space (i.e. hundreds of megabytes). Note
that on a modern x86/x64 CPU, arithmetic operations on floats are
not faster than arithmetic operations on doubles (except for
divisions, but these should be avoided, anyway).

--Mike