Namespace l2dbus.Uint64

L2DBUS Uint64

This section describes a Lua Uint64 type used to manipulate D-Bus Uint64 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 Uint64 types without loss of precision is problematic. As a result a Lua Uint64 type was created to wrap D-Bus Uint64 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 Uint64 type.

Several numerical operations are supported by this type. For binary operations the "other" number is first cast to an Uint64 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.Uint64

toNumber (value)
toString (value)


Functions

new (value, base)

Creates a new Uint64 value.

Parameters:

  • value number or string The number to convert to an Uint64. If passed in as a string the strtoul() 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 strtoul() for more details.

Returns:

    userdata The userdata object representing an Uint64.

l2dbus.Uint64

toNumber (value)

Converts the Uint64 to a Lua number.

In converting the Uint64 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 Uint64 value to convert to a Lua number.

Returns:

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

Converts the Uint64 to a string.

Parameters:

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

Returns:

    string A string representing the Uint64.
generated by LDoc 1.3