Simple Virtual Machine - Official plugin int(7)

SYNOPSIS
svm_plugin_int - Simple Virtual Machine official plugin for integer management.

DESCRIPTION
This plugin introduces extra features to manage built-in type INT values.

INVOKATION
This plugin can be added to the Simple Virtual Machine using the directive:
PLUGIN "svmint.so"

CONTENT

  INSTRUCTION int.add ( INT INT + | PTR ) -> INT
This instruction returns the sum of the parameters. If a pointer is provided, the memory zone shall contain initialised integers used to compute the sum, or a MEMORY interruption will be raised.

  INSTRUCTION int.cmp INT [ < > = <> <= => ] INT -> BLN
This instruction compares two integers and returns the result of the comparison. <> denotes the difference between two integers.

  INSTRUCTION int.div INT INT -> INT
This instruction returns the quotien between the two parameters. The instruction raises a NUMERIC interruption when the divider is zero.

  INSTRUCTION int.mod INT INT -> INT
This instruction returns the remainder between the two parameters. The instruction raises a NUMERIC interruption when the divider is zero.

  INSTRUCTION int.mul ( INT INT + | PTR ) -> INT
This instruction returns the product of the parameters. If a pointer is provided, the memory zone shall contain initialised integers used to compute the product, or a MEMORY interruption will be raised.

  INSTRUCTION int.gcd ( INT INT + | PTR ) -> INT
This instruction returns the greatest common divisor of the parameters. If a pointer is provided, the memory zone shall contain initialised integers used to compute the gcd, or a MEMORY interruption will be raised.

  INSTRUCTION int.lcm ( INT INT + | PTR ) -> INT
This instruction returns the least common multiple of the parameters. If a pointer is provided, the memory zone shall contain initialised integers used to compute the lcm, or a MEMORY interruption will be raised.

  INSTRUCTION int.parse STR -> INT
This instruction transforms a string into an integer. If the string does not contain only an integer, a NUMERIC interruption is raised. When the string starts with a 0, an octal interpretation is performed, when the string starts with 0x, an hexadecimal interpretation is performed.

  INSTRUCTION int.print INT ( [ 'OCT' 'DEC' 'HEX' ] INT ) ? -> STR
This instruction transforms an integer into a string. An optional format can be specified: a base ( OCT for octal output with a 0 prefix, DEC for decimal output, HEX for hexadecimal output with a 0x prefix) and a text size, prefix excluded.

  INSTRUCTION int.rand 'DICE' ? INT : limit -> INT
This instruction returns a pseudo random integer between 0 and the limit minus one. When the keyword DICE is specified, one is added to the random number.

  INSTRUCTION int.sub INT INT -> INT
This instruction returns the difference between the two parameters.

  Integer functions

  FUNCTION int.add ( INT INT + | PTR ) -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.sub INT INT -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.mul ( INT INT + | PTR ) -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.div INT INT -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.mod INT INT -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.gcd ( INT INT + | PTR ) -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.lcm ( INT INT + | PTR ) -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.cmp INT [ < > = <> <= => ] INT -> BLN
This function does the same operation as the corresponding instruction.

  FUNCTION int.parse STR -> INT
This function does the same operation as the corresponding instruction.

  FUNCTION int.print INT ( [ 'OCT' 'DEC' 'HEX' ] INT ) ? -> STR
This function does the same operation as the corresponding instruction.

  FUNCTION int.format INT INT:size STR:padding [ 'OCT' 'DEC' 'HEX' ] ? -> STR
This function renders the integer within a string. The returned string has the specified length, padded left with the given string. The integer is rendered in the specified base (DEC by default) without the base prefix.

SEE ALSO
svm(1) for help on the Simple Virtual Machine.

AUTHOR
The Simple Virtual Machine is designed, implemented and maintained by Julien Bruguier <===EMAILCONTACT===>.