Data.Int
The 64-bit signed integer, which the compiler provides.
Decimal, with a leading - for a negative number. The digits are peeled off
a non-positive copy, because minValue has no positive counterpart to peel
them from; % takes the dividend's sign, so each remainder is in -9..0.
Int is two's-complement 64-bit, so these are constants -- but the low one
cannot be written. -9223372036854775808 lexes as a unary minus applied
to 9223372036854775808, which is not an Int, so the literal is rejected
before the negation can rescue it. Subtracting from the representable
maximum is the way round it.
Floored, so the result takes the sign of the divisor and is therefore a
valid index for every positive b. % is remainder and takes the sign of
the dividend; the difference bites exactly where people reach for it, which
is bucket selection.
Panics on minValue(), which has no positive counterpart. That is the
trapping behaviour of neg, not an extra rule.
Returns the high 64 bits of the 128-bit product of a and b, both read as
unsigned. With mulWrapping, which is the low 64 bits, it is the whole
product.
Returns s read as a decimal Int, or None; see parseRadix.
Parses s in base radix, which must be in 2..36 (a panic otherwise).
Accepts what parse accepts, with digits 0-9 and then letters of either
case: an optional sign, then one or more digits, and nothing else -- no
0x prefix, no _, no surrounding space. Returns None for a digit
outside the radix or a value outside Int.
Formats n in base radix (2..36, a panic otherwise) with lowercase
letters for the digits above 9 and a leading - for a negative number.
Returns -1, 0 or 1 as n is negative, zero or positive.
Returns the quotient of a and b rounded toward negative infinity, which
pairs with mod: floorDiv(a, b) * b + mod(a, b) == a. Panics when b is
zero, and on floorDiv(minValue(), -1), as / does.
Returns (floorDiv(a, b), mod(a, b)).
Returns the greatest common divisor, never negative; gcd(0, 0) is 0.
Panics only when the answer is 2^63, that is, when one argument is
minValue() and the other is 0 or minValue().
Returns the least common multiple, never negative; zero when either argument
is zero. Panics on overflow, as * does.
Returns base raised to exp. Panics when exp is negative, because the
answer is not an Int, and on overflow, as * does; pow(0, 0) is 1.
Returns base raised to exp, modulo modulus, in 0..modulus - 1.
Panics when exp is negative or modulus is not positive. No intermediate
value overflows, whatever the modulus.
Returns the floor of the square root of n. Panics when n is negative.
Returns the number of set bits.
Returns the number of zero bits above the highest set bit: 64 for zero.
Returns the number of zero bits below the lowest set bit: 64 for zero.
All three panic outside 0..63 rather than masking the shift amount, so that
x << 64 is a reported bug and not a silent identity. shr is arithmetic:
the sign bit replicates. shrUnsigned is logical: zeros come in at the top.
The range is checked here rather than trusted to the primitive, which compiles to a single instruction: arm64 masks the shift amount to six bits, so shifting by 64 would quietly be a shift by zero.
The integers from from up to but not including to, as an iterator: empty
when from >= to. Exported without its constructor, and its cursor not at
all, so a range is only ever made by range.