Convert a boolean to an int64std/core/types/int64: 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
.
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
.
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
.
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
.
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
.
Convert an int32std/core/types/int32: V
to an int64std/core/types/int64: V
(using sign extension).
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.
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.
Are two 64-bit integers not equal?
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.
Multiply two 64-bit integers.
Add two 64-bit integers.
Subtract two 64-bit integers.
Euclidean-0 division.
Euclidean division is defined as: For any D
and d
where d!=0
, we have:
D == d*(D/d) + (D%d)
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:
D/(-d) == -(D/d)
D%(-d) == D%d
D/(2^n) == sarstd/num/int64/sar: (i : int64, shift : int) -> int64(D,n)
(with 0 <= n <= 63
)
D%(2n) == D & ((2n) - 1)
(with 0 <= n <= 63
)
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 .
Is the first 64-bit integer smaller than the second?
Is the first 64-bit integer smaller or equal to the second?
Are two 64-bit integers equal?
Is the first 64-bit integer larger than the second?
Is the first 64-bit integer larger or equal to the second?
Take the bitwise xor of two int64std/core/types/int64: V
s.
Negate an 64-bit integer.
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).
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).
Take the bitwise and of two int64std/core/types/int64: V
s.
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"
.
Reverse the bits in an 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"
.
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)
.
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)
.
The number of bits in an int64std/core/types/int64: V
(always 64).
Convert an int64std/core/types/int64: V
to a boolean.
Reverse the bytes in an 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
.
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
.
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.
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)
.
Count leading redundant sign bits (i.e. the number of bits following the most significant bit that are identical to it).
Count leading zero bits. Returns 64 if i
is zero.
Truncated modulus (as in C). See also (%):(x : int64std/core/types/int64: V, y : int64std/core/types/int64: V) -> int64std/core/types/int64: V
.
Count trailing zero bits. Returns 64 if i
is zero.
Decrement a 64-bit integer.
Return the top 32-bits of an int64std/core/types/int64: V
.
Preserves the sign.
Convenient shorthand to int64
, e.g. 1234.i64std/num/int64/i64: (i : int) -> int64
.
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
.
Increment a 64-bit integer.
Convert an int64_t
to an intstd/core/types/int: 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).
Clamp an intstd/core/types/int: V
to fit in an int64_t
.
Returns true
if the integer i
is an even number.
Is the 64-bit integer negative?
Returns true
if the integer i
is an odd number.
Is the 64-bit integer positive? (i.e. larger than zero).
Is the 64-bit integer zero?
Return the low 32-bits of an int64std/core/types/int64: V
.
Return the maximum of two integers.
The maximal integer value before overflow happens.
Return the minimum of two integers.
The minimal integer value before underflow happens.
Negate a 64-bit integer.
Bitwise not of an int64std/core/types/int64: V
, i.e. flips all bits.
The 64-bit integer for 1.
Take the bitwise or of two int64std/core/types/int64: V
s.
Or-combine: for every byte b
in the argument i
, the corresponding
byte in the result becomes 0 if b==0
, and 0xFF
otherwise.
Is the popcountstd/num/int64/popcount: (i : int64) -> int
even?
Count number of 1-bits.
Bitwise rotate an int64std/core/types/int64: V
n % 64
bits to the left.
Bitwise rotate an int64std/core/types/int64: V
n % 64
bits to the right.
Arithmetic shift an int64std/core/types/int64: V
to the right by n % 64
bits. Shift in the sign bit from the left.
Shift an int64std/core/types/int64: V
i
to the left by n % 64
bits.
Convert an int64std/core/types/int64: V
to a string.
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).
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.
Logical shift an int64std/core/types/int64: V
to the right by n % 64
bits. Shift in zeros from the left.
Compare a 64-integer to zero.
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
.
Convert an int32std/core/types/int32: V
to an int64std/core/types/int64: V
interpreting the int32std/core/types/int32: V
as unsigned.
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
.
Take the bitwise xor of two int64std/core/types/int64: V
s.
The 64-bit integer for zero.
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
.