lua-users home
lua-l archive

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

-----Original Message-----

Message: 1
Date: Wed, 10 Jul 2013 13:54:26 -0400
From: Todd Coram <>
Subject: Re: [ANN] Lua 5.3.0 (work1) now available
Content-Type: text/plain

On Wed, Jul 10, 2013, at 01:07 PM, Jay Carlson wrote:
> On Jul 10, 2013 12:47 PM, "Todd Coram" <[]> wrote:
> IMHO, Int64 is a very big deal (for Lua). The 53 bits of mantissa is 
> sufficient for a lot of applications, but I feel dirty every time I 
> deal with a protocol format that specifies a 64 bit field and I shove 
> it into a Lua (5.1/5.2) number: One day, someone will have a reason 
> for using all 64 bits in that field and my Lua app will munge that value.
> Yeah. But for many protocols the only things which get that large are lengths, and x86_64 implementations can't address that much memory. 64-bit ARM has that architected tag mode, so they hit the address space wall at ~2^55.

Not to be pedantic, but when protocol specifies 64 bit ints, it is expected to handle 64 bit ints. If someone decides to pack extra meta-information into the upper bits of a 64 bit numbers, my Lua code shouldn't munge it.

A few months ago I released a BSON parser in pure Lua and was questioned by the BSON folk whether I truly supported int64 ... well I don't :-(


Below are parts of a table describing data types used by DeviceNet and Ethernet/IP industrial protocols.  I work with these and use Lua to communicate with devices using this protocol.  The 64-bit data types are out of range for Lua and must be tested using Programmable Logic Controllers (PLCs).  To those arguing that even great computers do not use 64-bit types, PLCs are as far below great computers as is possible without losing the computer label.

The 64-bit type is most likely used to capture up to 64 flags in the industrial application in a single variable.  For example 64 binary inputs or 64 relay outputs.  Support for 64-bit types by Lua would allow my work to be done entirely on a lowly laptop without resorting to an even lower PLC.


Volume 1: Common Industrial Protocol Specification, Appendix C: Data Management
C-2.1.1 Elementary Data Types

Type		Description		Range
ULINT		Unsigned Long Integer	0 2^64-1
LWORD		bit string - 64-bits	NOTE 11

NOTE 11  Values of bit string data types is in the range 2#bN-1bN-2...b2b1b0, where N is the number of bits in the bit
string, bN-1 is the "most significant bit", and b0 is the "least significant bit". The value of the j-th bit bj is
represented as 0 or 1, corresponding to the Boolean value FALSE or TRUE, respectively.