"MachineInteger" (Compiled Type)

"MachineInteger"

represents a machine-sized signed integer atomic type specifier.

Details

  • "MachineInteger" can be used in Typed and related constructs to specify a type.
  • On 64-bit platforms, "MachineInteger" is an "Integer64".
  • On 32-bit platforms, "MachineInteger" is an "Integer32".
  • "MachineInteger" is useful for working with the "PackedArray" type.

Properties

  • Values held by "MachineInteger" range from -263 to 263-1 on 64-bit architectures.
  • Values held by "MachineInteger" range from -231 to 231-1 on 32-bit architectures.

Conversions

    From Expressions

  • Suitably sized Integer expressions can be converted into compiled code elements with the type "MachineInteger".
  • To Expressions

  • "MachineInteger" compiled elements can be converted into Integer expressions.
  • Arithmetic

  • "MachineInteger" compiled elements are automatically promoted to real or complex elements when they are combined in binary arithmetic operations.
  • Compiled elements with types smaller than "MachineInteger" are automatically promoted to "MachineInteger" when they are combined in binary arithmetic operations.
  • "MachineInteger" compiled elements are automatically promoted to "UnsignedMachineInteger" elements when they are combined in binary arithmetic operations.

Runtime Errors

    Overflow

  • "MachineInteger" can give a runtime error if it is used in an operation that overflows.

Examples

Basic Examples  (4)

"MachineInteger" can be used as an input and output from a CompiledCodeFunction:

"MachineInteger" has the same size as $SystemWordLength:

An overflow causes an error while running the function. The computation is terminated, a message is issued and the Wolfram Engine is used to compute the result:

The "MachineInteger" argument is automatically promoted when combined with a real number:

When an "MachineInteger" argument is combined with an integer of a smaller storage size, the smaller type is automatically promoted:

The "MachineInteger" argument is automatically promoted when combined with an unsigned integer of the same storage size:

"MachineInteger" is useful for working with "PackedArray", since this takes integers of the native size for the architecture: