Convert a boolean to an int32std/core/types/int32: V
.
Convert a pair (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32)
to a signed integer,
where (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32).int == histd/num/int32/hi: (i : int32) -> int32.int * 0x1_0000_0000 + lostd/num/int32/lo: (i : int32) -> int32.uint
.
Create an int32std/core/types/int32: V
from the give histd/num/int32/hi: (i : int32) -> int32
and lostd/num/int32/lo: (i : int32) -> int32
16-bit numbers.
Preserves the sign of histd/num/int32/hi: (i : int32) -> int32
.
Convert a pair (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32)
to an unsigned integer,
where (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32).uint == histd/num/int32/hi: (i : int32) -> int32.uint * 0x1_0000_0000 + lostd/num/int32/lo: (i : int32) -> int32.uint
.
Fold over the range [start,end]
(including end
).
Iterate over the range [start,end]
(including end
).
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.
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
.
Are two 32-bit integers not equal?
Euclidean-0 modulus. See (/):(x : int32std/core/types/int32: V, y : int32std/core/types/int32: V) -> int32std/core/types/int32: V
division for more information.
Multiply two 32-bit integers.
Add two 32-bit integers.
Subtract two 32-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/int32/sar: (i : int32, shift : int) -> int32(D,n)
(with 0 <= n <= 31
)
D%(2n) == D & ((2n) - 1)
(with 0 <= n <= 31
)
Note that an interesting edge case is min-int32std/num/int32/min-int32: int32 / -1
which equals min-int32std/num/int32/min-int32: int32
since in modulo 32-bit
arithmetic min-int32std/num/int32/min-int32: int32 == -1 * min-int32std/num/int32/min-int32: int32 == -1 * (min-int32std/num/int32/min-int32: int32 / -1) + (min-int32std/num/int32/min-int32: int32 % -1)
satisfying property (1).
Of course (min-int32std/num/int32/min-int32: int32 + 1) / -1
is again positive (namely max-int32std/num/int32/max-int32: int32
).
See also Division and modulus for computer scientists, Daan Leijen, 2001 pdf .
Is the first 32-bit integer smaller than the second?
Is the first 32-bit integer smaller or equal to the second?
Are two 32-bit integers equal?
Is the first 32-bit integer larger than the second?
Is the first 32-bit integer larger or equal to the second?
Take the bitwise xor of two int32std/core/types/int32: V
s.
Negate an 32-bit integer.
Return the absolute value of an integer.
Raises an exception if the int32std/core/types/int32: V
is min-int32std/num/int32/min-int32: int32
(since the negation of min-int32std/num/int32/min-int32: int32
equals itself and is still negative).
Return the absolute value of an integer.
Returns 0 if the int32std/core/types/int32: V
is min-int32std/num/int32/min-int32: int32
(since the negation of min-int32std/num/int32/min-int32: int32
equals itself and is still negative).
Take the bitwise and of two int32std/core/types/int32: 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.
bgather(0x1234.int32, 0x0F0F.int32).show-hex == "0x24"
Here is how to decode a 4-byte utf-8 encoded character i
:
bgather(i,0x3F3F3F3F.int32)
.
Reverse the bits in an int32std/core/types/int32: 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.
bscatter(0x1234.int32, 0x0F0F.int32).show-hex == "0x304"
.
De-interleave the bits in i
such that the odd bits are gathered in the
hi 16-bits of the result, and the even bits (starting at bit 0)
end up in the lo 16-bits of the result. bit-unzipstd/num/int32/bit-unzip: (i : int32) -> int32(x).andstd/num/int32/and: (int32, int32) -> int32(0xFFFF) == bit-gatherstd/num/int32/bit-gather: (i : int32, m : int32) -> int32(x,0x5555_5555.int32)
.
Interleave the hi 16-bits with the lo 16-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/int32/bit-zip: (i : int32) -> int32(x.andstd/num/int32/and: (int32, int32) -> int32(0xFFFF)) == bit-scatterstd/num/int32/bit-scatter: (i : int32, m : int32) -> int32(x,0x5555_5555.int32)
.
The number of bits in an int32std/core/types/int32: V
(always 32).
Convert an int32std/core/types/int32: V
to a boolean.
Reverse the bytes in an int32std/core/types/int32: V
.
Truncated division (as in C). See also (/):(x : int32std/core/types/int32: V, y : int32std/core/types/int32: V) -> int32std/core/types/int32: V
.
Carry-less multiplication (or xor multiplication).
See also https://en.wikipedia.org/wiki/Carry-less_product
Interesting cases:
- clmulstd/num/int32/clmul: (x : int32, y : int32) -> int32(x,x)
: bit spread, where a zero bit is put in between each input bit.
clmulstd/num/int32/clmul: (x : int32, y : int32) -> int32(x,x) == bit-scatterstd/num/int32/bit-scatter: (i : int32, m : int32) -> int32(x,0x5555_5555.int32) == bit-zipstd/num/int32/bit-zip: (i : int32) -> int32(andstd/num/int32/and: (int32, int32) -> int32(x,0xFFFF))
- clmulstd/num/int32/clmul: (x : int32, y : int32) -> int32(x,-1.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/int32/clmul: (x : int32, y : int32) -> int32(x,-1.int32).shrstd/num/int32/shr: (i : int32, shift : int) -> int32(31).bool == x.paritystd/num/int32/parity: (i : int32) -> bool
.
Wide carry-less multiplication (or xor multiplication) to (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32)
.
where (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32).int == histd/num/int32/hi: (i : int32) -> int32.int * 0x1_0000_0000 + lostd/num/int32/lo: (i : int32) -> int32.uint
See also https://en.wikipedia.org/wiki/Carry-less_product.
Reverse carry-less multiplication.
Defined as clmulrstd/num/int32/clmulr: (x : int32, y : int32) -> int32(x,y) == clmulstd/num/int32/clmul: (x : int32, y : int32) -> int32(x.bit-reversestd/num/int32/bit-reverse: (i : int32) -> int32,y.bitreverse).bitreverse
Also clmulrstd/num/int32/clmulr: (x : int32, y : int32) -> int32(x,x) == zipstd/core/list/zip: forall<a,b> (xs : list<a>, ys : list<b>) -> list<(a, b)>(x.andstd/num/int32/and: (int32, int32) -> int32(0xFFFF0000.int32)
, and
zipstd/core/list/zip: forall<a,b> (xs : list<a>, ys : list<b>) -> list<(a, b)>(x) == clmulstd/num/int32/clmul: (x : int32, y : int32) -> int32(x,x) | clmulrstd/num/int32/clmulr: (x : int32, y : int32) -> int32(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 32 if i
is zero.
Truncated modulus (as in C). See also (%):(x : int32std/core/types/int32: V, y : int32std/core/types/int32: V) -> int32std/core/types/int32: V
.
Count trailing zero bits. Returns 32 if i
is zero.
Decrement a 32-bit integer.
Convert an 32-bit integer to a float64.
Fold over the 32-bit integers 0
to malformed identifier: a dash must be preceded by a letter or digit, and followed by a letter
.
Iterate over the 32-bit integers 0
to malformed identifier: a dash must be preceded by a letter or digit, and followed by a letter
.
Return the top 16-bits of an int32std/core/types/int32: V
.
Preserves the sign.
Convenient shorthand to int32
, e.g. 1234.i32std/num/int32/i32: (i : int) -> int32
.
Full 32x32 bit signed multiply to (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32)
.
where imulstd/num/int32/imul: (i : int32, j : int32) -> (int32, int32)(x,y).int == x.int * y.int
.
Increment a 32-bit integer.
Convert an int32std/core/types/int32: V
to an intstd/core/types/int: V
.
Convert an integer to an int32std/core/types/int32: V
. The number is clamped to the maximal or minimum int32std/core/types/int32: V
value if it is outside the range of an int32std/core/types/int32: V
.
Needed for control flow contexts in std/core/hndstd/core/hnd
.
Returns true
if the integer i
is an even number.
Is the 32-bit integer negative?
Returns true
if the integer i
is an odd number.
Is the 32-bit integer positive (i.e. larger than zero)?
Is the 32-bit integer equal to zero?
Create a list with 32-bit integer elements from lostd/num/int32/lo: (i : int32) -> int32
to histd/num/int32/hi: (i : int32) -> int32
(including histd/num/int32/hi: (i : int32) -> int32
).
Return the low 16-bits of an int32std/core/types/int32: 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 32-bit integer.
Bitwise not of an int32std/core/types/int32: V
, i.e. flips all bits.
The 32-bit integer with value 1.
Take the bitwise or of two int32std/core/types/int32: 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/int32/popcount: (i : int32) -> int
even?
Count number of 1-bits (also known as population count or hamming weight).
Bitwise rotate an int32std/core/types/int32: V
n % 32
bits to the left.
Bitwise rotate an int32std/core/types/int32: V
n % 32
bits to the right.
Arithmetic shift an int32std/core/types/int32: V
to the right by n % 32
bits. Shifts in the sign bit from the left.
Shift an int32std/core/types/int32: V
i
to the left by n & 31
bits.
Convert an int32std/core/types/int32: V
to a string.
Show an int32std/core/types/int32: 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 int32std/core/types/int32: V
in hexadecimal notation interpreted as an unsigned 32-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 int32std/core/types/int32: V
to the right by n % 32
bits. Shift in zeros from the left.
Compare the argument against zero.
Convert an int32std/core/types/int32: V
to an intstd/core/types/int: V
but interpret the int32std/core/types/int32: V
as a 32-bit unsigned value.
Convert an intstd/core/types/int: V
to int32std/core/types/int32: V
but interpret the int
as an unsigned 32-bit value.
i
is clamped between 0
and 0xFFFFFFFF
.
0x7FFF_FFFF.uint32std/num/int32/uint32: (i : int) -> int32 == 0x7FFF_FFFF.int32 == max-int32std/num/int32/max-int32: int32
0x8000_0000.uint32std/num/int32/uint32: (i : int) -> int32 == -0x8000_0000.int32 == min-int32std/num/int32/min-int32: int32
0xFFFF_FFFF.uint32std/num/int32/uint32: (i : int) -> int32 == -1.int32
.
Full 32x32 bit unsigned multiply to (histd/num/int32/hi: (i : int32) -> int32,lostd/num/int32/lo: (i : int32) -> int32)
.
where umulstd/num/int32/umul: (i : int32, j : int32) -> (int32, int32)(x,y).uint == x.uint * y.uint
.
Truncated division (as in C). See also (/):(x : int32std/core/types/int32: V, y : int32std/core/types/int32: V) -> int32std/core/types/int32: V
.
Truncated modulus (as in C). See also (%):(x : int32std/core/types/int32: V, y : int32std/core/types/int32: V) -> int32std/core/types/int32: V
.
Take the bitwise xor of two int32std/core/types/int32: V
s.
The zero 32-bit integer.
32-bit signed integers.
Using 32-bit signed two's complement representation with wrapping on overflow, e.g.
max-int32std/num/int32/max-int32: int32 + 1.int32 == min-int32std/num/int32/min-int32: int32
.