Namespace l2dbus.Int64

L2DBUS Int64

This section describes a Lua Int64 type used to manipulate D-Bus Int64 types in the Lua environment.

Since Lua's fundamental numerical type in most installations is a floating point number (a 'C' double or float), supporting D-Bus Int64 types without loss of precision is problematic. As a result a Lua Int64 type was created to wrap D-Bus Int64 types and provide a means to manipulate and print these types from Lua. Likewise, these types can be added as arguments to D-Bus messages where they will be converted correctly to the underlying D-Bus Int64 type.

Several numerical operations are supported by this type. For binary operations the "other" number is first cast to an Int64 before the operator is applied. What this means is that standard Lua numbers which are floating point will be truncated and potentially lose information. Please be aware of this limitation when operating on these types. The operators supported include:

  • Addition (+)
  • Subtraction (-)
  • Multiplication (*)
  • Division (/)
  • Modulus (%)
  • Negation (-)
  • Equal (==)
  • Less Than (<)
  • Less Than Equal (<=)
  • Greater Than (>)
  • Greater Than Equal (>=)

Functions

new (value, base)

l2dbus.Int64

toNumber (value)
toString (value)


Functions

new (value, base)

Creates a new Int64 value.

Parameters:

  • value number or string The number to convert to an Int64. If passed in as a string the strtoll() function is used to convert the number to a numerical value.
  • base optional number The base must be in the range [2, 36] or equal to 0. See strtoll() for more details.

Returns:

    userdata The userdata object representing an Int64.

l2dbus.Int64

toNumber (value)

Converts the Int64 to a Lua number.

In converting the Int64 to a Lua number there is the chance of losing precision since Lua number's typically cannot precisely represent all integral values. For a Lua double this range is [-2^52, 2^52 -1].

Parameters:

  • value userdata The Int64 value to convert to a Lua number.

Returns:

    number A (possibly) equivalent Lua number.
toString (value)

Converts the Int64 to a string.

Parameters:

  • value userdata The Int64 value to convert to a string.

Returns:

    string A string representing the Int64.
generated by LDoc 1.3