# FixUtil Documentation

Back to summary

`import "util/long";`

## Long class

This class allows to work easilly with 64-bit signed integers.

- Members
- Initialization
- Operations
- Properties

### Members

`var lo: Integer;
var hi: Integer;
`
  The low and high order part of the 64-bit integer.

### Initialization

`static function create(): Long
static function create(value: Integer): Long
static function create(lo: Integer, hi: Integer): Long
`
  Creates a new long with given value (or zero).
`static function from_string(s: String): Long`
  Creates a new long from string representation, throwing an error on improper format.

### Operations

`function set(other: Long): Long
function set_int(value: Integer): Long
function set_string(s: String): Long
function set_raw(lo: Integer, hi: Integer): Long
`
  Sets the value. Returns itself.
`function dup(): Long`
  Creates a new long with the same value.
`function add(other: Long): Long
function add_int(value: Integer): Long
function add_mod(other: Long): Long
function add_mod_int(value: Integer): Long
`
  Adds another value into this. Returns itself. The `mod` variant is using modular arithmetic instead of throwing an error on overflow.
`function sub(other: Long): Long
function sub_int(value: Integer): Long
function sub_mod(other: Long): Long
function sub_mod_int(value: Integer): Long
`
  Subtracts another value from this. Returns itself. The `mod` variant is using modular arithmetic instead of throwing an error on overflow.
`function mul(other: Long): Long
function mul_int(value: Integer): Long
function mul_mod(other: Long): Long
function mul_mod_int(value: Integer): Long
`
  Multiplies another value with this. Returns itself. The `mod` variant is using modular arithmetic instead of throwing an error on overflow.
`function div(other: Long): Long
function div_int(value: Integer): Long
`
  Divides by another value and uses the result. Returns itself.
`function rem(other: Long): Long
function rem_int(value: Integer): Long
`
  Divides by another value and uses the remainder. Returns itself.
`function and(other: Long): Long
function and(lo: Integer, hi: Integer): Long
`
  Applies AND logic operation. Returns itself.
`function or(other: Long): Long
function or(lo: Integer, hi: Integer): Long
`
  Applies OR logic operation. Returns itself.
`function xor(other: Long): Long
function xor(lo: Integer, hi: Integer): Long
`
  Applies XOR logic operation. Returns itself.
`function not(): Long`
  Inverts the bits. Returns itself.
`function shl(amount: Integer): Long`
  Shifts the bits left (towards high order part). Only the low 6 bits are used from amount.
`function shr(amount: Integer): Long`
  Shifts the bits right (towards low order part), replicating the highest bit (arithmetic shift). Only the low 6 bits are used from amount.
`function ushr(amount: Integer): Long`
  Shifts the bits right (towards low order part), using zeros for the highest bits (logical/unsigned shift). Only the low 6 bits are used from amount.

### Properties

`function is_zero(): Boolean`
  Returns true when the value is zero.
`function cmp(other: Long): Integer
function cmp_int(value: Integer): Integer
`
  Compares the value with another integer. Returns negative result (when the value is smaller), zero (when the values are same) or positive result (when the value is bigger).
`function to_int(): Integer`
  Returns the value as 32-bit integer, throwing an error in case it can't fit.
`function to_string(): String`
  Returns the string representation of the value.