lua-users home
lua-l archive

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



On May 11, 2006, at 12:21, Stockdale, Daire, SOE wrote:

Is there any way to write to file the binary representation of a
lua_Number without using a custom module?

Well, what's wrong with an external module? :)

For example, Luiz Henrique de Figueiredo has a nice, tidy library just for that purpose:

"lpack — A library for packing and unpacking binary data."

"pack is called as follows: pack(F,x1,x2,...), where F is a string describing how the values x1, x2, ... are to be interpreted and formatted. Each letter in the format string F consumes one of the given values. Only values of type number or string are accepted. pack returns a (binary) string containing the values packed as described in F. The letter codes understood by pack are listed in lpack.c (they are inspired by Perl's codes but are not the same). Numbers
following letter codes in F indicate repetitions."

http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#lpack

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/