std/num/int64▲toc

64-bit signed integers.

Using 64-bit signed two's complement representation with wrapping on overflow, e.g. max-int64std/num/int64/max-int64: int64 + 1.int64 == min-int64std/num/int64/min-int64: int64.

fun bool/int64( b : boolstd/core/types/bool: V ) : int64std/core/types/int64: V

Convert a boolean to an int64std/core/types/int64: V.

fun hilo/int( (int64std/core/types/int64: V, int64std/core/types/int64: V) ) : intstd/core/types/int: V

Convert a pair (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64) to an signed integer, where (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64).int == histd/num/int64/hi: (i : int64) -> int64.int * 0x1_0000_0000_0000_0000 + lostd/num/int64/lo: (i : int64) -> int64.uint.

fun hilo/int64( hi : int64std/core/types/int64: V, lo : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Create an int64std/core/types/int64: V from the given histd/num/int64/hi: (i : int64) -> int64 and lostd/num/int64/lo: (i : int64) -> int64 numbers lowest 32-bits. Preserves the sign of histd/num/int64/hi: (i : int64) -> int64.

fun hilo/uint( (int64std/core/types/int64: V, int64std/core/types/int64: V) ) : intstd/core/types/int: V

Convert a pair (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64) to an unsigned integer, where (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64).uint == histd/num/int64/hi: (i : int64) -> int64.uint * 0x1_0000_0000_0000_0000 + lostd/num/int64/lo: (i : int64) -> int64.uint.

fun hilo32/int64( hi : int32std/core/types/int32: V, lo : int32std/core/types/int32: V ) : int64std/core/types/int64: V

Create an int64std/core/types/int64: V i from the bits of lostd/num/int64/lo: (i : int64) -> int64 and histd/num/int64/hi: (i : int64) -> int64 such that i.int = histd/num/int64/hi: (i : int64) -> int64.int * 0x1_0000_0000 + lostd/num/int64/lo: (i : int64) -> int64.uint.

fun int/uint64( i : intstd/core/types/int: V ) : int64std/core/types/int64: V

Convert an intstd/core/types/int: V to int64std/core/types/int64: V but interpret the int as an unsigned 64-bit value. i is clamped between 0 and 0xFFFF_FFFF_FFFF_FFFF.
0x7FFF_FFFF_FFFF_FFFF.uint64 == 0x7FFF_FFFF_FFFF_FFFF.int64 == max-int64std/num/int64/max-int64: int64
0x8000_0000_0000_0000.uint64 == -0x8000_0000_0000_0000.int64 == min-int64std/num/int64/min-int64: int64
0xFFFF_FFFF_FFFF_FFFF.uint64 == -1.int64.

fun int32/int64( i : int32std/core/types/int32: V ) : int64std/core/types/int64: V

Convert an int32std/core/types/int32: V to an int64std/core/types/int64: V (using sign extension).

fun int64/uint( i : int64std/core/types/int64: V ) : intstd/core/types/int: V

Convert an int64std/core/types/int64: V to an intstd/core/types/int: V but interpret the int64std/core/types/int64: V as a 64-bit unsigned value.

fun range/fold-int64( start : int64std/core/types/int64: V, end : int64std/core/types/int64: V, init : a, f : (int64std/core/types/int64: V, a) -> e a ) : e a
fun range/for-while64( start : int64std/core/types/int64: V, end : int64std/core/types/int64: V, ^action : (int64std/core/types/int64: V) -> e maybestd/core/types/maybe: V -> V<a> ) : e maybestd/core/types/maybe: V -> V<a>

Executes action for each integer between start upto end (including both start and end ). If start > end the function returns without any call to action . If action returns Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>, the iteration is stopped and the result returned.

fun (!=)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Are two 64-bit integers not equal?

fun (%)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Euclidean-0 modulus. See (/):(x : int64std/core/types/int64: V, y : int64std/core/types/int64: V) -> int64std/core/types/int64: V division for more information.

fun (*)( int64std/core/types/int64: V, int64std/core/types/int64: V ) : int64std/core/types/int64: V

Multiply two 64-bit integers.

fun (+)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Add two 64-bit integers.

fun (-)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Subtract two 64-bit integers.

fun (/)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Euclidean-0 division. Euclidean division is defined as: For any D and d where d!=0 , we have:

  1. D == d*(D/d) + (D%d)
  2. D%d is always positive where 0 <= D%d < abs(d)

Moreover, Euclidean-0 is a total function, for the case where d==0 we have that D%0 == D and D/0 == 0 . So property (1) still holds, but not property (2). Useful laws that hold for Euclidean-0 division:

Note that an interesting edge case is min-int64std/num/int64/min-int64: int64 / -1 which equals min-int64std/num/int64/min-int64: int64 since in modulo 64-bit arithmetic min-int64std/num/int64/min-int64: int64 == -1 * min-int64std/num/int64/min-int64: int64 == -1 * (min-int64std/num/int64/min-int64: int64 / -1) + (min-int64std/num/int64/min-int64: int64 % -1) satisfying property (1). Of course (min-int64std/num/int64/min-int64: int64 + 1) / -1 is again positive (namely max-int64std/num/int64/max-int64: int64).

See also Division and modulus for computer scientists, Daan Leijen, 2001 pdf .

fun (<)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the first 64-bit integer smaller than the second?

fun (<=)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the first 64-bit integer smaller or equal to the second?

fun (==)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Are two 64-bit integers equal?

fun (>)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the first 64-bit integer larger than the second?

fun (>=)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the first 64-bit integer larger or equal to the second?

fun (^)( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Take the bitwise xor of two int64std/core/types/int64: Vs.

fun (~)( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Negate an 64-bit integer.

fun abs( i : int64std/core/types/int64: V ) : exnstd/core/exn/exn: (E, V) -> V int64std/core/types/int64: V

Return the absolute value of an integer. Raises an exception if the int64std/core/types/int64: V is min-int64std/num/int64/min-int64: int64 (since the negation of min-int64std/num/int64/min-int64: int64 equals itself and is still negative).

fun abs0( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Return the absolute value of an integer. Returns 0 if the int64std/core/types/int64: V is min-int64std/num/int64/min-int64: int64 (since the negation of min-int64std/num/int64/min-int64: int64 equals itself and is still negative).

fun and( int64std/core/types/int64: V, int64std/core/types/int64: V ) : int64std/core/types/int64: V

Take the bitwise and of two int64std/core/types/int64: Vs.

fun bit-gather( i : int64std/core/types/int64: V, m : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Bit gather (also known as pext or parallel bit extract). For each 1-bit in mask m, extract the corresponding bit from i and write it into contiguous lower bits in the result. The remaining bits in the result are zero.

bit-gatherstd/num/int64/bit-gather: (i : int64, m : int64) -> int64(0x1234.int64, 0x0F0F.int64).show-hex == "0x24".

fun bit-reverse( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Reverse the bits in an int64std/core/types/int64: V.

fun bit-scatter( i : int64std/core/types/int64: V, m : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Bit scatter (also known as pdep or parallel bit deposit). For each 1-bit in mask m, set the corresponding bit in the result from the contiguous lower bits of i. Any bits not set according to the mask are set to zero.

bit-scatterstd/num/int64/bit-scatter: (i : int64, m : int64) -> int64(0x1234.int64, 0x0F0F.int64).show-hex == "0x304".

fun bit-unzip( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

De-interleave the bits in i such that the odd bits are gathered in the hi 32-bits of the result, and the even bits (starting at bit 0) end up in the lo 32-bits of the result. bit-unzipstd/num/int64/bit-unzip: (i : int64) -> int64(x).andstd/num/int64/and: (int64, int64) -> int64(0xFFFF_FFFF.int64) == bit-gatherstd/num/int64/bit-gather: (i : int64, m : int64) -> int64(x,0x5555_5555_5555_5555.int64).

fun bit-zip( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Interleave the hi 32-bits with the lo 32-bits of the argument i such that the hi bits are spread over the odd bits and the lo bits over the even bits of the result (starting at bit 0). bit-zipstd/num/int64/bit-zip: (i : int64) -> int64(x.andstd/num/int64/and: (int64, int64) -> int64(0xFFFF_FFFF.int64)) == bit-scatterstd/num/int64/bit-scatter: (i : int64, m : int64) -> int64(x,0x5555_5555_5555_5555.int64).

val bits-int64: int64std/core/types/int64: V

The number of bits in an int64std/core/types/int64: V (always 64).

fun bool( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Convert an int64std/core/types/int64: V to a boolean.

fun byte-reverse( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Reverse the bytes in an int64std/core/types/int64: V.

fun cdiv( i : int64std/core/types/int64: V, j : int64std/core/types/int64: V ) : exnstd/core/exn/exn: (E, V) -> V int64std/core/types/int64: V

Truncated division (as in C). See also (/):(x : int64std/core/types/int64: V, y : int64std/core/types/int64: V) -> int64std/core/types/int64: V.

fun clmul( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Carry-less multiplication (or xor multiplication). See also https://​en.​wikipedia.​org/​wiki/​Carry-​less_​product Interesting cases: - clmulstd/num/int64/clmul: (x : int64, y : int64) -> int64(x,x) : bit spread, where a zero bit is put in between each input bit. clmulstd/num/int64/clmul: (x : int64, y : int64) -> int64(x,x) == bit-scatterstd/num/int64/bit-scatter: (i : int64, m : int64) -> int64(x,0x5555_5555_5555_5555.int64) == bit-zipstd/num/int64/bit-zip: (i : int64) -> int64(andstd/num/int64/and: (int64, int64) -> int64(x,0xFFFF_FFFF.int64)) - clmulstd/num/int64/clmul: (x : int64, y : int64) -> int64(x,-1.int32std/num/int64/int32: (i : int64) -> int32): prefix xor, where each bit is the parity of the corresponding input bit and all input bits before it (the xor sum). clmulstd/num/int64/clmul: (x : int64, y : int64) -> int64(x,-1.int64).shrstd/num/int64/shr: (i : int64, shift : int) -> int64(63).bool == x.paritystd/num/int64/parity: (i : int64) -> bool.

fun clmul-wide( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : (int64std/core/types/int64: V, int64std/core/types/int64: V)

Wide carry-less multiplication (or xor multiplication) to (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64), where (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64).int == histd/num/int64/hi: (i : int64) -> int64.int * 0x1_0000_0000_0000_0000 + lostd/num/int64/lo: (i : int64) -> int64.uint. See also https://​en.​wikipedia.​org/​wiki/​Carry-​less_​product.

fun clmulr( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Reverse carry-less multiplication. Defined as clmulrstd/num/int64/clmulr: (x : int64, y : int64) -> int64(x,y) == clmulstd/num/int64/clmul: (x : int64, y : int64) -> int64(x.bit-reversestd/num/int64/bit-reverse: (i : int64) -> int64,y.bitreverse).bitreverse Interesting cases: - clmulrstd/num/int64/clmulr: (x : int64, y : int64) -> int64(x,x) == zipstd/core/list/zip: forall<a,b> (xs : list<a>, ys : list<b>) -> list<(a, b)>(x.andstd/num/int64/and: (int64, int64) -> int64(0xFFFF_FFFF_0000_0000.int64), and - zipstd/core/list/zip: forall<a,b> (xs : list<a>, ys : list<b>) -> list<(a, b)>(x) == clmulstd/num/int64/clmul: (x : int64, y : int64) -> int64(x,x) | clmulrstd/num/int64/clmulr: (x : int64, y : int64) -> int64(x,x).

fun clrsb( i : int64std/core/types/int64: V ) : intstd/core/types/int: V

Count leading redundant sign bits (i.e. the number of bits following the most significant bit that are identical to it).

fun clz( i : int64std/core/types/int64: V ) : intstd/core/types/int: V

Count leading zero bits. Returns 64 if i is zero.

fun cmod( i : int64std/core/types/int64: V, j : int64std/core/types/int64: V ) : exnstd/core/exn/exn: (E, V) -> V int64std/core/types/int64: V

Truncated modulus (as in C). See also (%):(x : int64std/core/types/int64: V, y : int64std/core/types/int64: V) -> int64std/core/types/int64: V.

fun cmp( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : orderstd/core/types/order: V
fun ctz( i : int64std/core/types/int64: V ) : intstd/core/types/int: V

Count trailing zero bits. Returns 64 if i is zero.

fun dec( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Decrement a 64-bit integer.

fun divmod( x : int64std/core/types/int64: V, y : int64std/core/types/int64: V ) : (int64std/core/types/int64: V, int64std/core/types/int64: V)
fun fold-int64( n : int64std/core/types/int64: V, init : a, f : (int64std/core/types/int64: V, a) -> e a ) : e a
fun for-while64( n : int64std/core/types/int64: V, ^action : (int64std/core/types/int64: V) -> e maybestd/core/types/maybe: V -> V<a> ) : e maybestd/core/types/maybe: V -> V<a>
fun hi( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Return the top 32-bits of an int64std/core/types/int64: V. Preserves the sign.

fun i64( i : intstd/core/types/int: V ) : int64std/core/types/int64: V

Convenient shorthand to int64, e.g. 1234.i64std/num/int64/i64: (i : int) -> int64.

fun imul( i : int64std/core/types/int64: V, j : int64std/core/types/int64: V ) : (int64std/core/types/int64: V, int64std/core/types/int64: V)

Full 64x64 to 128-bit signed multiply to (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64). where imulstd/num/int64/imul: (i : int64, j : int64) -> (int64, int64)(x,y).int == x.int * y.int.

fun inc( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Increment a 64-bit integer.

fun int( i : int64std/core/types/int64: V ) : intstd/core/types/int: V

Convert an int64_t to an intstd/core/types/int: V.

fun int32( i : int64std/core/types/int64: V ) : int32std/core/types/int32: V

Clamp an int64std/core/types/int64: V to an int32std/core/types/int32: V -1.int64.int32std/num/int64/int32: (i : int64) -> int32 == -1.int32std/num/int64/int32: (i : int64) -> int32 0x8000_0000.int64.int32std/num/int64/int32: (i : int64) -> int32 == 0x7FFF_FFFF.int32std/num/int64/int32: (i : int64) -> int32 (clamped).

fun int64( i : intstd/core/types/int: V ) : int64std/core/types/int64: V

Clamp an intstd/core/types/int: V to fit in an int64_t.

fun is-even( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Returns true if the integer i is an even number.

fun is-neg( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the 64-bit integer negative?

fun is-odd( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Returns true if the integer i is an odd number.

fun is-pos( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the 64-bit integer positive? (i.e. larger than zero).

fun is-zero( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the 64-bit integer zero?

fun list64( lo : int64std/core/types/int64: V, hi : int64std/core/types/int64: V ) : liststd/core/types/list: V -> V<int64std/core/types/int64: V>
fun lo( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Return the low 32-bits of an int64std/core/types/int64: V.

fun max( i : int64std/core/types/int64: V, j : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Return the maximum of two integers.

val max-int64: int64std/core/types/int64: V

The maximal integer value before overflow happens.

fun min( i : int64std/core/types/int64: V, j : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Return the minimum of two integers.

val min-int64: int64std/core/types/int64: V

The minimal integer value before underflow happens.

fun negate( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Negate a 64-bit integer.

fun not( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Bitwise not of an int64std/core/types/int64: V, i.e. flips all bits.

val one: int64std/core/types/int64: V

The 64-bit integer for 1.

fun or( int64std/core/types/int64: V, int64std/core/types/int64: V ) : int64std/core/types/int64: V

Take the bitwise or of two int64std/core/types/int64: Vs.

fun orc( i : int64std/core/types/int64: V ) : int64std/core/types/int64: V

Or-combine: for every byte b in the argument i, the corresponding byte in the result becomes 0 if b==0, and 0xFF otherwise.

fun parity( i : int64std/core/types/int64: V ) : boolstd/core/types/bool: V

Is the popcountstd/num/int64/popcount: (i : int64) -> int even?

fun popcount( i : int64std/core/types/int64: V ) : intstd/core/types/int: V

Count number of 1-bits.

fun rotl( i : int64std/core/types/int64: V, shift : intstd/core/types/int: V ) : int64std/core/types/int64: V

Bitwise rotate an int64std/core/types/int64: V n % 64 bits to the left.

fun rotr( i : int64std/core/types/int64: V, shift : intstd/core/types/int: V ) : int64std/core/types/int64: V

Bitwise rotate an int64std/core/types/int64: V n % 64 bits to the right.

fun sar( i : int64std/core/types/int64: V, shift : intstd/core/types/int: V ) : int64std/core/types/int64: V

Arithmetic shift an int64std/core/types/int64: V to the right by n % 64 bits. Shift in the sign bit from the left.

fun shl( i : int64std/core/types/int64: V, shift : intstd/core/types/int: V ) : int64std/core/types/int64: V

Shift an int64std/core/types/int64: V i to the left by n % 64 bits.

fun show( i : int64std/core/types/int64: V ) : stringstd/core/types/string: V

Convert an int64std/core/types/int64: V to a string.

fun show-hex( i : int64std/core/types/int64: V, width : ? intstd/core/types/int: V, use-capitals : ? boolstd/core/types/bool: V, pre : ? stringstd/core/types/string: V ) : stringstd/core/types/string: V

Show an int64std/core/types/int64: V in hexadecimal notation The width parameter specifies how wide the hex value is where '0' is used to align.
The use-capitals parameter (= Truestd/core/types/True: bool) determines if captical letters should be used to display the hexadecimal digits.
The pre (="0x") is an optional prefix for the number (goes between the sign and the number).

fun show-hex64( i : int64std/core/types/int64: V, width : ? intstd/core/types/int: V, use-capitals : ? boolstd/core/types/bool: V, pre : ? stringstd/core/types/string: V ) : stringstd/core/types/string: V

Show an int64std/core/types/int64: V in hexadecimal notation interpreted as an unsigned 64-bit value. The width parameter specifies how wide the hex value is where '0' is used to align.
The use-capitals parameter (= Truestd/core/types/True: bool) determines if captical letters should be used to display the hexadecimal digits.
The pre (="0x") is an optional prefix for the number.

fun shr( i : int64std/core/types/int64: V, shift : intstd/core/types/int: V ) : int64std/core/types/int64: V

Logical shift an int64std/core/types/int64: V to the right by n % 64 bits. Shift in zeros from the left.

fun sign( i : int64std/core/types/int64: V ) : orderstd/core/types/order: V

Compare a 64-integer to zero.

fun sum64( xs : liststd/core/types/list: V -> V<int64std/core/types/int64: V> ) : int64std/core/types/int64: V
fun uint32( i : int64std/core/types/int64: V ) : int32std/core/types/int32: V

Clamp an int64std/core/types/int64: V to an int32std/core/types/int32: V but interpreting the int32std/core/types/int32: V as unsigned (and thus clamp between 0 and 0xFFFFFFFF). -1.int64.uint32std/num/int64/uint32: (i : int64) -> int32 == 0.int32std/num/int64/int32: (i : int64) -> int32 (clamped) 0xFFFFFFFF.int64.uint32std/num/int64/uint32: (i : int64) -> int32 == -1.int32std/num/int64/int32: (i : int64) -> int32.

fun uint64( i : int32std/core/types/int32: V ) : int64std/core/types/int64: V

Convert an int32std/core/types/int32: V to an int64std/core/types/int64: V interpreting the int32std/core/types/int32: V as unsigned.

fun umul( i : int64std/core/types/int64: V, j : int64std/core/types/int64: V ) : (int64std/core/types/int64: V, int64std/core/types/int64: V)

Full 64x64 to 128-bit unsigned multiply to (histd/num/int64/hi: (i : int64) -> int64,lostd/num/int64/lo: (i : int64) -> int64). where umulstd/num/int64/umul: (i : int64, j : int64) -> (int64, int64)(x,y).uint == x.uint * y.uint.

fun xor( int64std/core/types/int64: V, int64std/core/types/int64: V ) : int64std/core/types/int64: V

Take the bitwise xor of two int64std/core/types/int64: Vs.

val zero: int64std/core/types/int64: V

The 64-bit integer for zero.

private import std/core/typesstd/core/types, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/boolstd/core/bool, std/core/orderstd/core/order, std/core/charstd/core/char, std/core/intstd/core/int, std/core/vectorstd/core/vector, std/core/stringstd/core/string, std/core/sslicestd/core/sslice, std/core/liststd/core/list, std/core/maybestd/core/maybe, std/core/eitherstd/core/either, std/core/tuplestd/core/tuple, std/core/showstd/core/show, std/core/debugstd/core/debug, std/core/delayedstd/core/delayed, std/core/consolestd/core/console, std/corestd/core, std/core/undivstd/core/undiv