diff --git a/src/compiler.c b/src/compiler.c index 2e57321..d7f24c0 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -705,39 +705,22 @@ static void defineVariable(size_t global) { static void number(int exprType) { const char * start = parser.previous.start; invalidTarget(exprType, "literal"); - int base = 10; - /* - * Handle base prefixes: - * 0x Hexadecimal - * 0b Binary - * 0o Octal - */ - if (start[0] == '0' && (start[1] == 'x' || start[1] == 'X')) { - base = 16; - start += 2; - } else if (start[0] == '0' && (start[1] == 'b' || start[1] == 'B')) { - base = 2; - start += 2; - } else if (start[0] == '0' && (start[1] == 'o' || start[1] == 'O')) { - base = 8; - start += 2; - } - - /* If it wasn't a special base, it may be a floating point value. */ - if (base == 10) { - for (size_t j = 0; j < parser.previous.length; ++j) { - if (parser.previous.start[j] == '.') { - double value = strtod(start, NULL); - emitConstant(FLOATING_VAL(value)); - return; - } + for (size_t j = 0; j < parser.previous.length; ++j) { + if (parser.previous.start[j] == '.') { + double value = strtod(start, NULL); + emitConstant(FLOATING_VAL(value)); + return; } } /* If we got here, it's an integer of some sort. */ - krk_integer_type value = parseStrInt(start, NULL, base); - emitConstant(INTEGER_VAL(value)); + KrkValue result = krk_parse_int(start, parser.previous.literalWidth, 0); + if (IS_NONE(result)) { + error("invalid numeric literal"); + return; + } + emitConstant(result); } static int emitJump(uint8_t opcode) { @@ -2566,7 +2549,7 @@ static void string(int exprType) { } \ tmpbuf[i] = c[i+2]; \ } \ - unsigned long value = parseStrInt(tmpbuf, NULL, 16); \ + unsigned long value = strtoul(tmpbuf, NULL, 16); \ if (value >= 0x110000) { \ error("invalid codepoint in \\%c escape", type); \ } \ diff --git a/src/kuroko/kuroko.h b/src/kuroko/kuroko.h index e3ed3a8..038b425 100644 --- a/src/kuroko/kuroko.h +++ b/src/kuroko/kuroko.h @@ -11,9 +11,6 @@ typedef int64_t krk_integer_type; #define ENABLE_THREADING -#define PRIkrk_int "%" PRId64 -#define PRIkrk_hex "%" PRIx64 -#define parseStrInt strtoll #if defined(KRK_DISABLE_THREADS) || defined(__EMSCRIPTEN__) || defined(EFI_PLATFORM) # undef ENABLE_THREADING diff --git a/src/kuroko/object.h b/src/kuroko/object.h index 1a98cb9..20f7a45 100644 --- a/src/kuroko/object.h +++ b/src/kuroko/object.h @@ -233,6 +233,7 @@ typedef struct KrkClass { KrkObj * _floordiv, * _rfloordiv, * _ifloordiv; KrkObj * _lt, * _gt, * _le, * _ge; + KrkObj * _invert, * _negate; } KrkClass; /** diff --git a/src/kuroko/value.h b/src/kuroko/value.h index 7e9a562..830f7bb 100644 --- a/src/kuroko/value.h +++ b/src/kuroko/value.h @@ -180,6 +180,8 @@ extern int krk_valuesEqual(KrkValue a, KrkValue b); */ extern int krk_valuesSame(KrkValue a, KrkValue b); +extern KrkValue krk_parse_int(const char * start, size_t width, unsigned int base); + typedef union { KrkValue val; double dbl; @@ -233,3 +235,7 @@ typedef union { #define KWARGS_DICT (INT32_MAX-2) #define KWARGS_NIL (INT32_MAX-3) #define KWARGS_UNSET (0) + +#define PRIkrk_int "%" PRId64 +#define PRIkrk_hex "%" PRIx64 + diff --git a/src/kuroko/vm.h b/src/kuroko/vm.h index 49f9b76..310956d 100644 --- a/src/kuroko/vm.h +++ b/src/kuroko/vm.h @@ -122,6 +122,7 @@ struct BaseClasses { KrkClass * bytearrayClass; /**< Mutable array of bytes */ KrkClass * dictvaluesClass; /**< Iterator over values of a dict */ KrkClass * sliceClass; /**< Slice object */ + KrkClass * longClass; /**< Arbitrary precision integer */ }; /** diff --git a/src/methods.h b/src/methods.h index 14b2bd5..9439a1d 100644 --- a/src/methods.h +++ b/src/methods.h @@ -40,6 +40,8 @@ CACHED_METHOD(LT, "__lt__", _lt) CACHED_METHOD(GT, "__gt__", _gt) CACHED_METHOD(LE, "__le__", _le) CACHED_METHOD(GE, "__ge__", _ge) +CACHED_METHOD(INVERT, "__invert__", _invert) +CACHED_METHOD(NEGATE, "__neg__", _negate) /* These are not methods */ SPECIAL_ATTRS(CLASS, "__class__") diff --git a/src/obj_long.c b/src/obj_long.c new file mode 100644 index 0000000..127435d --- /dev/null +++ b/src/obj_long.c @@ -0,0 +1,1358 @@ +/** + * @file obj_long.c + * @brief Big ints, implemented through my own makeshift thing + * @author K. Lange + * + * Simple, slightly incomplete implementation of a 'long' type. + * Conceptually, several things were learned from Python: we store + * our longs as a sequence of 31-bit unsigned digits, combined with + * a signed count of digits - negative for a negative number, positive + * for a positive number, and 0 for 0. + * + * + * TODO: + * - Implement float conversions and @c __truediv__. + * - Expose better functions for extracting and converting native integers, + * which would be useful in modules that want to take 64-bit values, + * extracted unsigned values, etc. + * - Faster division for large divisors? + * - Shifts without multiply/divide... + * - Exponentiation... + */ +#include +#include +#include + +#define DIGIT_SHIFT 31 +#define DIGIT_MAX 0x7FFFFFFF + +struct KrkLong_Internal { + ssize_t width; + uint32_t *digits; +}; + +typedef struct KrkLong_Internal KrkLong; + +/** + * @brief Initialize an untouched KrkLong with a signed 64-bit value. + * + * This should always be called at least once for every KrkLong. + */ +static int krk_long_init_si(KrkLong * num, int64_t val) { + + /* Special-case for 0: width = 0, no digits. */ + if (val == 0) { + num->width = 0; + num->digits = NULL; + return 0; + } + + /* Digits store unsigned values, so flip things over. */ + int sign = (val < 0) ? -1 : 1; + uint64_t abs = (val < 0) ? -val : val; + + /* Quick case for things that fit in our digits... */ + if (abs <= DIGIT_MAX) { + num->width = sign; + num->digits = malloc(sizeof(uint32_t)); + num->digits[0] = abs; + return 0; + } + + /* Figure out how many digits we need. */ + uint64_t tmp = abs; + int64_t cnt = 1; + + while (tmp > DIGIT_MAX) { + cnt++; + tmp >>= DIGIT_SHIFT; + } + + /* Allocate space */ + num->width = cnt * sign; + num->digits = malloc(sizeof(uint32_t) * cnt); + + /* Extract digits. */ + for (int64_t i = 0; i < cnt; ++i) { + num->digits[i] = (abs & DIGIT_MAX); + abs >>= DIGIT_SHIFT; + } + + return 0; +} + +/** + * @brief Variadic initializer. All values become 0. + * + * Be sure to pass a NULL at the end... + */ +static int krk_long_init_many(KrkLong *a, ...) { + va_list argp; + va_start(argp, a); + + KrkLong * next = a; + while (next) { + krk_long_init_si(next, 0); + next = va_arg(argp, KrkLong *); + } + + va_end(argp); + return 0; +} + +/** + * @brief Initialize a new long by copying the digits from an + * existing, initialized long. + * + * The input value @p in may be a 0 value, but must be initialized. + */ +static int krk_long_init_copy(KrkLong * out, const KrkLong * in) { + size_t abs_width = in->width < 0 ? -in->width : in->width; + out->width = in->width; + out->digits = out->width ? malloc(sizeof(uint32_t) * abs_width) : NULL; + for (size_t i = 0; i < abs_width; ++i) { + out->digits[i] = in->digits[i]; + } + return 0; +} + + +/** + * @brief Free the space used for digits. + * + * @p num will have a value of 0 and is not itself freed. + */ +static int krk_long_clear(KrkLong * num) { + if (num->digits) free(num->digits); + num->width = 0; + num->digits = NULL; + return 0; +} + +/** + * @brief Variadic form of @c krk_long_clear + * + * Be sure to pass a NULL at the end... + */ +static int krk_long_clear_many(KrkLong *a, ...) { + va_list argp; + va_start(argp, a); + + KrkLong * next = a; + while (next) { + krk_long_clear(next); + next = va_arg(argp, KrkLong *); + } + + va_end(argp); + return 0; +} + +/** + * @brief Resize an initialized long to fit more digits. + * + * If @p newdigits is fewer digits than @p num already has, + * it will not be resized. @p num may be a 0 value. + */ +static int krk_long_resize(KrkLong * num, ssize_t newdigits) { + if (newdigits == 0) { + krk_long_clear(num); + return 0; + } + + size_t abs = newdigits < 0 ? -newdigits : newdigits; + size_t eabs = num->width < 0 ? -num->width : num->width; + if (num->width == 0) { + num->digits = malloc(sizeof(uint32_t) * newdigits); + } else if (eabs < abs) { + num->digits = realloc(num->digits, sizeof(uint32_t) * newdigits); + } + + num->width = newdigits; + return 0; +} + +/** + * @brief Update the sign of a long. + * + * Inverts the width of @p num as necessary. + */ +static int krk_long_set_sign(KrkLong * num, int sign) { + num->width = num->width < 0 ? (-num->width) * sign : num->width * sign; + return 0; +} + +/** + * @brief Remove trailing zeros from a long. + * + * I don't think I made this work right if the value _is_ zero, so, + * uh, make sure you deal with that... + */ +static int krk_long_trim(KrkLong * num) { + int invert = num->width < 0; + size_t owidth = invert ? -num->width : num->width; + size_t redundant = 0; + for (size_t i = 0; i < owidth; i++) { + if (num->digits[owidth-i-1] == 0) { + redundant++; + } else { + break; + } + } + + if (redundant) { + krk_long_resize(num, owidth - redundant); + if (invert) krk_long_set_sign(num, -1); + } + + return 0; +} + +/** + * @brief Compare two long values. + * + * Suitable for a traditional sort comparison. + * + * @return 0 if @p a and @p b are the same, -1 if @p a is less than @p b and + * 1 if @p a is greater than @p b + */ +static int krk_long_compare(const KrkLong * a, const KrkLong * b) { + if (a->width > b->width) return 1; + if (b->width > a->width) return -1; + int sign = a->width < 0 ? -1 : 1; + size_t abs_width = a->width < 0 ? -a->width : a->width; + for (size_t i = 0; i < abs_width; ++i) { + if (a->digits[abs_width-i-1] > b->digits[abs_width-i-1]) return sign; /* left is bigger */ + if (a->digits[abs_width-i-1] < b->digits[abs_width-i-1]) return -sign; /* right is bigger */ + } + return 0; /* they are the same */ +} + +/** + * @brief Compare two long values, ignoring their signs. + * + * Compares the absolute values of two longs. Basically the same + * as @c krk_long_compare but without using the signs in the comparison... + */ +static int krk_long_compare_abs(const KrkLong * a, const KrkLong * b) { + size_t a_width = a->width < 0 ? -a->width : a->width; + size_t b_width = b->width < 0 ? -b->width : b->width; + if (a_width > b_width) return 1; + if (b_width > a_width) return -1; + size_t abs_width = a_width; + for (size_t i = 0; i < abs_width; ++i) { + if (a->digits[abs_width-i-1] > b->digits[abs_width-i-1]) return 1; /* left is bigger */ + if (a->digits[abs_width-i-1] < b->digits[abs_width-i-1]) return -1; /* right is bigger */ + } + return 0; /* they are the same */ +} + +/** + * @brief Add the absolute value of two longs to make a third. + * + * @p res must be initialized to 0 beforehand and will have a positive value on return. + * It may not be the same value as @p a or @p b. + */ +static int krk_long_add_ignore_sign(KrkLong * res, const KrkLong * a, const KrkLong * b) { + size_t awidth = a->width < 0 ? -a->width : a->width; + size_t bwidth = b->width < 0 ? -b->width : b->width; + size_t owidth = awidth < bwidth ? bwidth + 1 : awidth + 1; + size_t carry = 0; + krk_long_resize(res, owidth); + for (size_t i = 0; i < owidth - 1; ++i) { + uint32_t out = (i < awidth ? a->digits[i] : 0) + (i < bwidth ? b->digits[i] : 0) + carry; + res->digits[i] = out & DIGIT_MAX; + carry = out > DIGIT_MAX; + } + if (carry) { + res->digits[owidth-1] = 1; + } else { + krk_long_resize(res, owidth - 1); + } + return 0; +} + +/** + * @brief Subtract a smaller number from a bigger number. + * + * Performs res = |a|-|b|, assuming |a|>|b|. + */ +static int _sub_big_small(KrkLong * res, const KrkLong * a, const KrkLong * b) { + /* Subtract b from a, where a is bigger */ + size_t awidth = a->width < 0 ? -a->width : a->width; + size_t bwidth = b->width < 0 ? -b->width : b->width; + size_t owidth = awidth; + + krk_long_resize(res, owidth); + + int carry = 0; + + for (size_t i = 0; i < owidth; ++i) { + /* We'll do long subtraction? */ + int64_t a_digit = (int64_t)(i < awidth ? a->digits[i] : 0) - carry; + int64_t b_digit = i < bwidth ? b->digits[i] : 0; + if (a_digit < b_digit) { + a_digit += 1 << DIGIT_SHIFT; + carry = 1; + } else { + carry = 0; + } + + res->digits[i] = (a_digit - b_digit) & DIGIT_MAX; + } + + krk_long_trim(res); + + return 0; +} + +/** + * @brief Quickly swap the contents of two initialized longs. + */ +static int _swap(KrkLong * a, KrkLong * b) { + ssize_t width = a->width; + uint32_t * digits = a->digits; + a->width = b->width; + a->digits = b->digits; + b->width = width; + b->digits = digits; + return 0; +} + +/* Macros for handling cases where res = a or res = b */ +#define PREP_OUTPUT(res,a,b) KrkLong _tmp_out_ ## res, *_swap_out_ ## res = NULL; do { if (res == a || res == b) { krk_long_init_si(&_tmp_out_ ## res, 0); _swap_out_ ## res = res; res = &_tmp_out_ ## res; } } while (0) +#define PREP_OUTPUT1(res,a) KrkLong _tmp_out_ ## res, *_swap_out_ ## res = NULL; do { if (res == a) { krk_long_init_si(&_tmp_out_ ## res, 0); _swap_out_ ## res = res; res = &_tmp_out_ ## res; } } while (0) +#define FINISH_OUTPUT(res) do { if (_swap_out_ ## res) { _swap(_swap_out_ ## res, res); krk_long_clear(&_tmp_out_ ## res); } } while (0) + +/** + * @brief Public interface to perform addition. + * + * Adds @p a and @p b together into @p res. + */ +static int krk_long_add(KrkLong * res, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(res,a,b); + + if (a->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,b); + FINISH_OUTPUT(res); + return 0; + } else if (b->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,a); + FINISH_OUTPUT(res); + return 0; + } + + if (a->width < 0 && b->width > 0) { + switch (krk_long_compare_abs(a,b)) { + case -1: + _sub_big_small(res,b,a); + krk_long_set_sign(res,1); + FINISH_OUTPUT(res); + return 0; + case 1: + _sub_big_small(res,a,b); + krk_long_set_sign(res,-1); + FINISH_OUTPUT(res); + return 0; + } + return 1; + } else if (a->width > 0 && b->width < 0) { + switch (krk_long_compare_abs(a,b)) { + case -1: + _sub_big_small(res,b,a); + krk_long_set_sign(res,-1); + FINISH_OUTPUT(res); + return 0; + case 1: + _sub_big_small(res,a,b); + krk_long_set_sign(res,1); + FINISH_OUTPUT(res); + return 0; + } + FINISH_OUTPUT(res); + return 1; + } + + /* sign must match for this, so take it from whichever */ + int sign = a->width < 0 ? -1 : 1; + if (krk_long_add_ignore_sign(res,a,b)) { + FINISH_OUTPUT(res); + return 1; + } + krk_long_set_sign(res,sign); + FINISH_OUTPUT(res); + return 0; +} + +/** + * @brief Public interface to perform subtraction. + * + * Subtracts @p b from @p b into @p res. + */ +static int krk_long_sub(KrkLong * res, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(res,a,b); + if (a->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,b); + krk_long_set_sign(res, b->width < 0 ? 1 : -1); + FINISH_OUTPUT(res); + return 0; + } else if (b->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,a); + FINISH_OUTPUT(res); + return 0; + } + + if ((a->width < 0) != (b->width < 0)) { + if (krk_long_add_ignore_sign(res,a,b)) { FINISH_OUTPUT(res); return 1; } + krk_long_set_sign(res,a->width < 0 ? -1 : 1); + FINISH_OUTPUT(res); + return 0; + } + + /* Which is bigger? */ + switch (krk_long_compare_abs(a,b)) { + case 0: + krk_long_clear(res); + FINISH_OUTPUT(res); + return 0; + case 1: + _sub_big_small(res,a,b); + if (a->width < 0) krk_long_set_sign(res, -1); + FINISH_OUTPUT(res); + return 0; + case -1: + _sub_big_small(res,b,a); + if (b->width > 0) krk_long_set_sign(res, -1); + FINISH_OUTPUT(res); + return 0; + } + + __builtin_unreachable(); +} + +/** + * @brief Zero all of the digits in @p num + * + * @p num remains untrimmed and will maintain these extra zeros. + */ +static int krk_long_zero(KrkLong * num) { + size_t abs_width = num->width < 0 ? -num->width : num->width; + for (size_t i = 0; i < abs_width; ++i) { + num->digits[i] = 0; + } + return 0; +} + +/** + * @brief Multiply the absolute values of two longs. + * + * Performs a simple chalkboard long multiplication, using the + * result as the accumulator. + * + * @p res must be initialized, but will be resized and zeroed on entry; it + * must not be equal to either of @p a or @p b. + */ +static int _mul_abs(KrkLong * res, const KrkLong * a, const KrkLong * b) { + + size_t awidth = a->width < 0 ? -a->width : a->width; + size_t bwidth = b->width < 0 ? -b->width : b->width; + + krk_long_resize(res, awidth+bwidth); + krk_long_zero(res); + + for (size_t i = 0; i < bwidth; ++i) { + uint64_t b_digit = b->digits[i]; + uint64_t carry = 0; + for (size_t j = 0; j < awidth; ++j) { + uint64_t a_digit = a->digits[j]; + uint64_t tmp = carry + a_digit * b_digit + res->digits[i+j]; + carry = tmp >> DIGIT_SHIFT; + res->digits[i+j] = tmp & DIGIT_MAX; + } + res->digits[i + awidth] = carry; + } + + krk_long_trim(res); + + return 0; +} + +/** + * @brief Public interface for multiplication. + * + * Multiplies @p a by @p b and places the result in @p res. + */ +static int krk_long_mul(KrkLong * res, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(res,a,b); + + if (a->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,a); + FINISH_OUTPUT(res); + return 0; + } + + if (b->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,b); + FINISH_OUTPUT(res); + return 0; + } + + if (_mul_abs(res,a,b)) { + FINISH_OUTPUT(res); + return 1; + } + + if ((a->width < 0) == (b->width < 0)) { + krk_long_set_sign(res,1); + } else { + krk_long_set_sign(res,-1); + } + + FINISH_OUTPUT(res); + return 0; +} + +/** + * @brief Shift a long one bit left. + * + * Shifts @p in left one bit in-place, resizing as needed. + */ +static int _lshift_one(KrkLong * in) { + if (in->width == 0) { + return 0; + } + + size_t abs_width = in->width < 0 ? -in->width : in->width; + size_t out_width = abs_width; + + if (in->digits[abs_width-1] >> (DIGIT_SHIFT - 1)) { + out_width += 1; + } + + krk_long_resize(in, out_width); + + int carry = 0; + + for (size_t i = 0; i < abs_width; ++i) { + uint32_t digit = in->digits[i]; + in->digits[i] = ((digit << 1) + carry) & DIGIT_MAX; + carry = (digit >> (DIGIT_SHIFT -1)); + } + + if (carry) { + in->digits[out_width-1] = 1; + } + + return 0; +} + +/** + * @brief Calculate the highest set bit of a long. + * + * TODO obviously since this returns a 'size_t', we only support + * numbers with that many bits, which is probably 1/8th + * what we could theoretically support, but whatever... + */ +static size_t _bits_in(const KrkLong * num) { + if (num->width == 0) return 0; + + size_t abs_width = num->width < 0 ? -num->width : num->width; + + /* Top bit in digits[abs_width-1] */ + size_t c = 0; + uint32_t digit = num->digits[abs_width-1]; + while (digit) { + c++; + digit >>= 1; + } + + return c + (abs_width-1) * DIGIT_SHIFT; +} + +/** + * @brief Check if a given bit is a set in a long. + */ +static size_t _bit_is_set(const KrkLong * num, size_t bit) { + size_t digit_offset = bit / DIGIT_SHIFT; + size_t digit_bit = bit % DIGIT_SHIFT; + return !!(num->digits[digit_offset] & (1 << digit_bit)); +} + +/** + * @brief Set or unset the least significant bit of a long. + */ +static int _bit_set_zero(KrkLong * num, int val) { + if (num->width == 0) { + krk_long_clear(num); + krk_long_init_si(num, !!val); + return 0; + } + + num->digits[0] = (num->digits[0] & ~1) | (!!val); + return 0; +} + +/** + * @brief Set a given bit in a long. + * + * Because of how we use it, this only supports setting the bit, + * eg. it performs: num |= (1 << bit) + * + * @p num will be resized as needed. + */ +static int krk_long_bit_set(KrkLong * num, size_t bit) { + size_t abs_width = num->width < 0 ? -num->width : num->width; + size_t digit_offset = bit / DIGIT_SHIFT; + size_t digit_bit = bit % DIGIT_SHIFT; + + if (digit_offset >= abs_width) { + krk_long_resize(num, digit_offset+1); + for (size_t i = abs_width; i < digit_offset + 1; ++i) { + num->digits[i] = 0; + } + } + + num->digits[digit_offset] |= (1 << digit_bit); + return 0; +} + +/** + * @brief Internal division implementation. + * + * Divides @p |a| by @p |b| placing the remainder in @p rem and the quotient in @p quot. + * + * Performs one of two division operations. For single-digit divisor, we perform + * a quicker division. For anything else, performs a binary long division, which + * is terribly slow, but is at least correct... + * + * @return 1 if divisor is 0, otherwise 0. + */ +static int _div_abs(KrkLong * quot, KrkLong * rem, const KrkLong * a, const KrkLong * b) { + /* quot = a / b; rem = a % b */ + + /* Zero quotiant and remainder */ + krk_long_clear(quot); + krk_long_clear(rem); + + if (b->width == 0) return 1; /* div by zero */ + if (a->width == 0) return 0; /* div of zero */ + + size_t awidth = a->width < 0 ? -a->width : a->width; + size_t bwidth = b->width < 0 ? -b->width : b->width; + + if (bwidth == 1 && b->digits[0] == 1) { + krk_long_init_copy(quot, a); + krk_long_set_sign(quot, 1); + return 0; + } + + if (awidth < bwidth) { + krk_long_init_copy(rem, a); + krk_long_set_sign(rem, 1); + return 0; + } + + KrkLong absa, absb; + krk_long_init_copy(&absa, a); + krk_long_set_sign(&absa, 1); + krk_long_init_copy(&absb, b); + krk_long_set_sign(&absb, 1); + + if (bwidth == 1) { + uint64_t remainder = 0; + for (size_t i = 0; i < awidth; ++i) { + size_t _i = awidth - i - 1; + remainder = (remainder << DIGIT_SHIFT) | absa.digits[_i]; + absa.digits[_i] = (uint32_t)(remainder / absb.digits[0]) & DIGIT_MAX; + remainder -= (uint64_t)(absa.digits[_i]) * absb.digits[0]; + } + + krk_long_init_si(rem, remainder); + _swap(quot, &absa); + krk_long_trim(quot); + + krk_long_clear_many(&absa, &absb, NULL); + return 0; + } + + size_t bits = _bits_in(a); + for (size_t i = 0; i < bits; ++i) { + size_t _i = bits - i - 1; + + /* Shift remainder by one */ + _lshift_one(rem); + + int is_set = _bit_is_set(&absa, _i); + _bit_set_zero(rem, is_set); + if (krk_long_compare(rem,&absb) >= 0) { + _sub_big_small(rem,rem,&absb); + krk_long_bit_set(quot, _i); + } + } + + krk_long_trim(quot); + krk_long_clear_many(&absa,&absb,NULL); + + return 0; +} + +/** + * @brief Public interface to division/modulo. + * + * Also does the Python-defined flooring / remainder inversion. + * + * @p quot or @p rem may be equal to @p a or @p b and I sure hope I got all + * the temporary swap value juggling done correctly... + * + * @return 1 if @p b is 0, 0 otherwise. + */ +static int krk_long_div_rem(KrkLong * quot, KrkLong * rem, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(quot,a,b); + PREP_OUTPUT(rem,a,b); + if (_div_abs(quot,rem,a,b)) { + FINISH_OUTPUT(rem); + FINISH_OUTPUT(quot); + return 1; + } + + if ((a->width < 0) != (b->width < 0)) { + /* Round down if remainder */ + if (rem->width) { + KrkLong one; + krk_long_init_si(&one, 1); + krk_long_add(quot, quot, &one); + _sub_big_small(rem, b, rem); + krk_long_clear(&one); + } + + /* Signs are different, negate and round down if necessary */ + krk_long_set_sign(quot, -1); + } + + if (b->width < 0) { + krk_long_set_sign(rem, -1); + } + + FINISH_OUTPUT(rem); + FINISH_OUTPUT(quot); + return 0; +} + +/** + * @brief Get the absolute value of a long. + * + * Basically just copies @p in to @p out and sets @p out 's sign to 1. + */ +static int krk_long_abs(KrkLong * out, const KrkLong * in) { + PREP_OUTPUT1(out,in); + krk_long_clear(out); + krk_long_init_copy(out, in); + krk_long_set_sign(out, 1); + FINISH_OUTPUT(out); + return 0; +} + +/** + * @brief Get the "sign" of a long. + * + * @return 0 if @p num == 0, -1 if @p num < 0, 1 if @p num > 0 + */ +static int krk_long_sign(const KrkLong * num) { + if (num->width == 0) return 0; + return num->width < 0 ? -1 : 1; +} + +/** + * @brief Estimate how many digits are needed to convert a long to a base. + * + * Dumb. Should be exact for a handful of powers of two, overestimates for + * everything else, so deal with that on your own... + */ +size_t krk_long_digits_in_base(KrkLong * num, int base) { + if (num->width == 0) return 1; + + size_t bits = _bits_in(num); + + if (base < 4) return bits; + if (base < 8) return (bits+1)/2; + if (base < 16) return (bits+2)/3; + if (base == 16) return (bits+3)/4; + return 0; +} + +/** + * @brief Get a small value as a uint32_t. + * + * Mostly just used for the string conversion... + */ +static uint32_t krk_long_short(KrkLong * num) { + if (num->width == 0) return 0; + return num->digits[0]; +} + +/** + * @brief Convert a long with up to 2 digits to a 64-bit value. + */ +static int64_t krk_long_medium(KrkLong * num) { + if (num->width == 0) return 0; + + if (num->width < 0) { + uint64_t val = num->digits[0]; + if (num->width < 1) { + val |= (num->digits[1]) << 31; + } + return -val; + } else { + uint64_t val = num->digits[0]; + if (num->width > 1) { + val |= (num->digits[1]) << 31; + } + return val; + } +} + +/** + * @brief Implementation for multiple bitwise operators. + * + * Supports or, xor, (and) and. Does in-place twos-complement for + * negatives - I thought that was pretty neat, but it's probably + * slower than just doing it afterwards... + */ +static int do_bin_op(KrkLong * res, const KrkLong * a, const KrkLong * b, char op) { + size_t awidth = a->width < 0 ? -a->width : a->width; + size_t bwidth = b->width < 0 ? -b->width : b->width; + size_t owidth = ((awidth > bwidth) ? awidth : bwidth) + 1; + + int aneg = (a->width < 0); + int bneg = (b->width < 0); + int rneg = 0; + + switch (op) { + case '|': rneg = aneg | bneg; break; + case '^': rneg = aneg ^ bneg; break; + case '&': rneg = aneg & bneg; break; + } + + krk_long_resize(res, owidth); + + int acarry = aneg ? 1 : 0; + int bcarry = bneg ? 1 : 0; + int rcarry = rneg ? 1 : 0; + + for (size_t i = 0; i < owidth; ++i) { + uint32_t a_digit = (i < awidth ? a->digits[i] : 0); + a_digit = aneg ? ((a_digit ^ DIGIT_MAX) + acarry) : a_digit; + acarry = a_digit >> DIGIT_SHIFT; + + uint32_t b_digit = (i < bwidth ? b->digits[i] : 0); + b_digit = bneg ? ((b_digit ^ DIGIT_MAX) + bcarry) : b_digit; + bcarry = b_digit >> DIGIT_SHIFT; + + uint32_t r; + switch (op) { + case '|': r = a_digit | b_digit; break; + case '^': r = a_digit ^ b_digit; break; + case '&': r = a_digit & b_digit; break; + default: __builtin_unreachable(); + } + + r = rneg ? (((r & DIGIT_MAX) ^ DIGIT_MAX) + rcarry) : r; + res->digits[i] = r & DIGIT_MAX; + rcarry = r >> DIGIT_SHIFT; + } + + krk_long_trim(res); + + if (rneg) { + krk_long_set_sign(res,-1); + } + + return 0; +} + +/** + * @brief Public interface for bitwise or. + */ +static int krk_long_or(KrkLong * res, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(res,a,b); + if (a->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,b); + FINISH_OUTPUT(res); + return 0; + } else if (b->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,a); + FINISH_OUTPUT(res); + return 0; + } + + int out = do_bin_op(res,a,b,'|'); + FINISH_OUTPUT(res); + return out; +} + +/** + * @brief Public interface for bitwise xor. + */ +static int krk_long_xor(KrkLong * res, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(res,a,b); + int out = do_bin_op(res,a,b,'^'); + FINISH_OUTPUT(res); + return out; +} + +/** + * @brief Public interface for bitwise and. + */ +static int krk_long_and(KrkLong * res, const KrkLong * a, const KrkLong * b) { + PREP_OUTPUT(res,a,b); + if (a->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,a); + FINISH_OUTPUT(res); + return 0; + } else if (b->width == 0) { + krk_long_clear(res); + krk_long_init_copy(res,b); + FINISH_OUTPUT(res); + return 0; + } + + int out = do_bin_op(res,a,b,'&'); + FINISH_OUTPUT(res); + return out; +} + +/** + * @brief Convert a long to a string in a given base. + */ +static char * krk_long_to_str(const KrkLong * n, int _base, const char * prefix, size_t *size) { + static const char vals[] = "0123456789abcdef"; + KrkLong abs, mod, base; + + krk_long_init_si(&abs, 0); + krk_long_init_si(&mod, 0); + krk_long_init_si(&base, _base); + + krk_long_abs(&abs, n); + + int sign = krk_long_sign(n); /* -? +? 0? */ + + size_t len = (sign == -1 ? 1 : 0) + krk_long_digits_in_base(&abs,_base) + strlen(prefix) + 1; + char * tmp = malloc(len); + char * writer = tmp; + + if (sign == 0) { + *writer++ = '0'; + } else { + while (krk_long_sign(&abs) > 0) { + krk_long_div_rem(&abs,&mod,&abs,&base); + *writer++ = vals[krk_long_short(&mod)]; + } + } + + while (*prefix) { *writer++ = *prefix++; } + if (sign < 0) *writer++ = '-'; + + char * rev = malloc(len); + char * out = rev; + while (writer != tmp) { + writer--; + *out++ = *writer; + } + *out = '\0'; + + free(tmp); + + krk_long_clear_many(&abs,&mod,&base,NULL); + *size = strlen(rev); + + return rev; +} + +static int is_valid(int base, char c) { + if (c < '0') return 0; + if (base <= 10) { + return c < ('0' + base); + } + + if (c >= 'a' && c < 'a' + (base - 10)) return 1; + if (c >= 'A' && c < 'A' + (base - 10)) return 1; + if (c >= '0' && c <= '9') return 1; + return 0; +} + +static int convert_digit(char c) { + if (c >= '0' && c <= '9') { + return c - '0'; + } + if (c >= 'a' && c <= 'z') { + return c - 'a' + 0xa; + } + if (c >= 'A' && c <= 'Z') { + return c - 'A' + 0xa; + } + return 0; +} + +/** + * @brief Parse a number into a long. + * + * This is now the main number parse for the compiler as well as being + * used when you pass a string to @c int or @c long. + * + * @return 0 on success, something else on failure. + */ +static int krk_long_parse_string(const char * str, KrkLong * num, unsigned int base, size_t len) { + const char * end = str + len; + const char * c = str; + int sign = 1; + + /* Skip any leading whitespace */ + while (c < end && *c && (*c == ' ' || *c == '\t')) c++; + + /* If there's nothing here, that's invalid. */ + if (c >= end) { + return 1; + } + + if (*c == '-') { + sign = -1; + c++; + } else if (*c == '+') { + c++; + } + + /* Just a sign is not valid... */ + if (c >= end) { + return 1; + } + + /* If base was not specified, accept a prefix. */ + if (base == 0) { + base = 10; + if (*c == '0') { + c++; + + if (c == end) { + /* If we saw just '0', that's fine... */ + krk_long_init_si(num, 0); + return 0; + } + + if (*c == 'x' || *c == 'X') { + base = 16; + c++; + } else if (*c == 'o' || *c == 'O') { + base = 8; + c++; + } else if (*c == 'b' || *c == 'B') { + base = 2; + c++; + } else { + return 2; + } + } + } + + if (c >= end) { + return 1; + } + + krk_long_init_si(num, 0); + + KrkLong _base, scratch; + krk_long_init_si(&_base, base); + krk_long_init_si(&scratch, 0); + + while (c < end && *c) { + if (*c == '_') c++; + if (c == (str + len) || !is_valid(base, *c)) { + krk_long_clear_many(&_base, &scratch, num, NULL); + return 1; + } + krk_long_mul(num, num, &_base); + krk_long_clear(&scratch); + krk_long_init_si(&scratch, convert_digit(*c)); + krk_long_add(num, num, &scratch); + c++; + } + + if (sign == -1) { + krk_long_set_sign(num, -1); + } + + krk_long_clear_many(&_base, &scratch, NULL); + return 0; +} + +static KrkClass * _long; + +typedef KrkLong krk_long[1]; + +struct BigInt { + KrkInstance inst; + krk_long value; +}; + +#define AS_long(o) ((struct BigInt *)AS_OBJECT(o)) +#define IS_long(o) (krk_isInstanceOf(o, _long)) + +#define CURRENT_CTYPE struct BigInt * +#define CURRENT_NAME self + +static void make_long(krk_integer_type t, struct BigInt * self) { + krk_long_init_si(self->value, t); +} + +static void _long_gcsweep(KrkInstance * self) { + krk_long_clear(((struct BigInt*)self)->value); +} + +KRK_METHOD(long,__init__,{ + METHOD_TAKES_AT_MOST(1); + if (argc < 2) { + make_long(0,self); + } else if (IS_INTEGER(argv[1])) { + make_long(AS_INTEGER(argv[1]),self); + } else if (IS_BOOLEAN(argv[1])) { + make_long(AS_BOOLEAN(argv[1]),self); + } else if (IS_STRING(argv[1])) { + if (krk_long_parse_string(AS_CSTRING(argv[1]),self->value,0,AS_STRING(argv[1])->length)) { + return krk_runtimeError(vm.exceptions->valueError, "invalid literal for long() with base 0: '%s'", AS_CSTRING(argv[1])); + } + } else if (IS_long(argv[1])) { + krk_long_init_copy(self->value,AS_long(argv[1])->value); + } else { + return krk_runtimeError(vm.exceptions->typeError, "%s() argument must be a string or a number, not '%s'", "int", krk_typeName(argv[1])); + } + /* our value should be set */ + return argv[0]; +}) + +#if 0 +KRK_METHOD(long,__float__,{ + return FLOATING_VAL(krk_long_get_double(self->value)); +}) +#endif + +#define PRINTER(name,base,prefix) \ + KRK_METHOD(long,__ ## name ## __,{ \ + size_t size; \ + char * rev = krk_long_to_str(self->value, base, prefix, &size); \ + return OBJECT_VAL(krk_takeString(rev,size)); \ + }) + +PRINTER(str,10,"") +PRINTER(hex,16,"x0") +PRINTER(oct,8,"o0") +PRINTER(bin,2,"b0") + +KRK_METHOD(long,__hash__,{ + return INTEGER_VAL((uint32_t)(krk_long_medium(self->value))); +}) + +static KrkValue make_long_obj(KrkLong * val) { + krk_integer_type maybe = 0; + if (val->width == 0) { + maybe = 0; + } else if (val->width == 1) { + maybe = val->digits[0]; + } else if (val->width == -1) { + maybe = -(int64_t)val->digits[0]; + } else if (val->width == 2 && (val->digits[1] & 0xFFFF0000) == 0) { + maybe = ((uint64_t)val->digits[1] << 31) | val->digits[0]; + } else if (val->width == -2 && (val->digits[1] && 0xFFFF0000) == 0) { + maybe = -(((uint64_t)val->digits[1] << 31) | val->digits[0]); + } else { + krk_push(OBJECT_VAL(krk_newInstance(_long))); + *AS_long(krk_peek(0))->value = *val; + return krk_pop(); + } + + krk_long_clear(val); + return INTEGER_VAL(maybe); +} + +KrkValue krk_parse_int(const char * start, size_t width, unsigned int base) { + KrkLong _value; + if (krk_long_parse_string(start, &_value, base, width)) { + return NONE_VAL(); + } + + return make_long_obj(&_value); +} + +KRK_METHOD(long,__int__,{ + return INTEGER_VAL(krk_long_medium(self->value)); +}) + +#define BASIC_BIN_OP(name, long_func) \ + KRK_METHOD(long,__ ## name ## __,{ \ + krk_long tmp; \ + if (IS_long(argv[1])) krk_long_init_copy(tmp, AS_long(argv[1])->value); \ + else if (IS_INTEGER(argv[1])) krk_long_init_si(tmp, AS_INTEGER(argv[1])); \ + else return NOTIMPL_VAL(); \ + long_func(tmp,self->value,tmp); \ + return make_long_obj(tmp); \ + }) \ + KRK_METHOD(long,__r ## name ## __,{ \ + krk_long tmp; \ + if (IS_long(argv[1])) krk_long_init_copy(tmp, AS_long(argv[1])->value); \ + else if (IS_INTEGER(argv[1])) krk_long_init_si(tmp, AS_INTEGER(argv[1])); \ + else return NOTIMPL_VAL(); \ + long_func(tmp,tmp,self->value); \ + return make_long_obj(tmp); \ + }) \ + _noexport \ + KrkValue krk_long_coerced_ ## name (krk_integer_type a, krk_integer_type b) { \ + krk_long tmp_res, tmp_a, tmp_b; \ + krk_long_init_si(tmp_res, 0); \ + krk_long_init_si(tmp_a, a); \ + krk_long_init_si(tmp_b, b); \ + long_func(tmp_res, tmp_a, tmp_b); \ + krk_long_clear_many(tmp_a, tmp_b, NULL); \ + return make_long_obj(tmp_res); \ + } + +BASIC_BIN_OP(add,krk_long_add) +BASIC_BIN_OP(sub,krk_long_sub) +BASIC_BIN_OP(mul,krk_long_mul) +BASIC_BIN_OP(or, krk_long_or) +BASIC_BIN_OP(xor,krk_long_xor) +BASIC_BIN_OP(and,krk_long_and) + +static void _krk_long_lshift(krk_long out, krk_long val, krk_long shift) { + if (krk_long_sign(shift) < 0) { krk_runtimeError(vm.exceptions->valueError, "negative shift count"); return; } + krk_long multiplier; + krk_long_init_si(multiplier,0); + krk_long_bit_set(multiplier, krk_long_medium(shift)); + krk_long_mul(out,val,multiplier); + krk_long_clear(multiplier); +} + +static void _krk_long_rshift(krk_long out, krk_long val, krk_long shift) { + if (krk_long_sign(shift) < 0) { krk_runtimeError(vm.exceptions->valueError, "negative shift count"); return; } + krk_long multiplier, garbage; + krk_long_init_many(multiplier,garbage,NULL); + krk_long_bit_set(multiplier, krk_long_medium(shift)); + krk_long_div_rem(out,garbage,val,multiplier); + krk_long_clear_many(multiplier,garbage,NULL); +} + +static void _krk_long_mod(krk_long out, krk_long a, krk_long b) { + if (krk_long_sign(b) == 0) { krk_runtimeError(vm.exceptions->valueError, "integer division or modulo by zero"); return; } + krk_long garbage; + krk_long_init_si(garbage,0); + krk_long_div_rem(garbage,out,a,b); + krk_long_clear(garbage); +} + +static void _krk_long_div(krk_long out, krk_long a, krk_long b) { + if (krk_long_sign(b) == 0) { krk_runtimeError(vm.exceptions->valueError, "integer division or modulo by zero"); return; } + krk_long garbage; + krk_long_init_si(garbage,0); + krk_long_div_rem(out,garbage,a,b); + krk_long_clear(garbage); +} + +BASIC_BIN_OP(lshift,_krk_long_lshift) +BASIC_BIN_OP(rshift,_krk_long_rshift) +BASIC_BIN_OP(mod,_krk_long_mod) +BASIC_BIN_OP(floordiv,_krk_long_div) + +#define COMPARE_OP(name, comp) \ + KRK_METHOD(long,__ ## name ## __,{ \ + krk_long tmp; \ + if (IS_long(argv[1])) krk_long_init_copy(tmp, AS_long(argv[1])->value); \ + else if (IS_INTEGER(argv[1])) krk_long_init_si(tmp, AS_INTEGER(argv[1])); \ + else return NOTIMPL_VAL(); \ + int cmp = krk_long_compare(self->value,tmp); \ + krk_long_clear(tmp); \ + return BOOLEAN_VAL(cmp comp 0); \ + }) + +COMPARE_OP(lt, <) +COMPARE_OP(gt, >) +COMPARE_OP(le, <=) +COMPARE_OP(ge, >=) +COMPARE_OP(eq, ==) + +#undef BASIC_BIN_OP +#undef COMPARE_OP + +KRK_METHOD(long,__len__,{ + return INTEGER_VAL(krk_long_sign(self->value)); +}) + +KRK_METHOD(long,__invert__,{ + KrkLong tmp, one; + krk_long_init_copy(&tmp, self->value); + krk_long_init_si(&one, 1); + krk_long_add(&tmp, &tmp, &one); + krk_long_set_sign(&tmp, tmp.width > 0 ? -1 : 1); + krk_long_clear(&one); + return make_long_obj(&tmp); +}) + +KRK_METHOD(long,__neg__,{ + KrkLong tmp; + krk_long_init_copy(&tmp, self->value); + krk_long_set_sign(&tmp, tmp.width > 0 ? -1 : 1); + return make_long_obj(&tmp); +}) + +#undef BIND_METHOD +#define BIND_METHOD(klass,method) do { krk_defineNative(& _ ## klass->methods, #method, _ ## klass ## _ ## method); } while (0) +_noexport +void _createAndBind_longClass(void) { + _long = ADD_BASE_CLASS(vm.baseClasses->longClass, "long", vm.baseClasses->intClass); + _long->allocSize = sizeof(struct BigInt); + _long->_ongcsweep = _long_gcsweep; + + BIND_METHOD(long,__init__); + BIND_METHOD(long,__str__); + BIND_METHOD(long,__eq__); + BIND_METHOD(long,__hash__); + BIND_METHOD(long,__hex__); + BIND_METHOD(long,__oct__); + BIND_METHOD(long,__bin__); + BIND_METHOD(long,__int__); + BIND_METHOD(long,__len__); + krk_defineNative(&_long->methods,"__repr__", FUNC_NAME(long,__str__)); + +#define BIND_TRIPLET(name) \ + BIND_METHOD(long,__ ## name ## __); \ + BIND_METHOD(long,__r ## name ## __); \ + krk_defineNative(&_long->methods,"__i" #name "__",_long___ ## name ## __); + BIND_TRIPLET(add); + BIND_TRIPLET(sub); + BIND_TRIPLET(mul); + BIND_TRIPLET(or); + BIND_TRIPLET(xor); + BIND_TRIPLET(and); + BIND_TRIPLET(lshift); + BIND_TRIPLET(rshift); + BIND_TRIPLET(mod); + //BIND_TRIPLET(truediv); + BIND_TRIPLET(floordiv); +#undef BIND_TRIPLET + + BIND_METHOD(long,__lt__); + BIND_METHOD(long,__gt__); + BIND_METHOD(long,__le__); + BIND_METHOD(long,__ge__); + BIND_METHOD(long,__invert__); + BIND_METHOD(long,__neg__); + + krk_finalizeClass(_long); +} + + diff --git a/src/obj_numeric.c b/src/obj_numeric.c index 5e122fe..d07d056 100644 --- a/src/obj_numeric.c +++ b/src/obj_numeric.c @@ -16,7 +16,7 @@ FUNC_SIG(int,__init__) { static __attribute__ ((unused)) const char* _method_name = "__init__"; - METHOD_TAKES_AT_MOST(1); + METHOD_TAKES_AT_MOST(2); if (argc < 2) return INTEGER_VAL(0); if (IS_BOOLEAN(argv[1])) return INTEGER_VAL(AS_INTEGER(argv[1])); if (IS_INTEGER(argv[1])) return argv[1]; @@ -52,14 +52,40 @@ KRK_METHOD(int,__hash__,{ return INTEGER_VAL((uint32_t)AS_INTEGER(argv[0])); }) +/** + * We _could_ use the __builtin_XXX_overflow(_p) functions gcc+clang provide, + * but let's just do this ourselves, I guess? + * + * We cheat: We only bother calculating + checking if both values would fit + * in int32_t's. This ensures multiplication works fine. + * + * For any case where an int32_t would overflow, we do the 'long' operation + * and then reduce if that still yields something that would fit in our 'int48'. + */ +#define OVERFLOW_CHECKED_INT_OPERATION(name,operator) \ + extern KrkValue krk_long_coerced_ ## name (krk_integer_type a, krk_integer_type b); \ + _noexport \ + KrkValue krk_int_op_ ## name (krk_integer_type a, krk_integer_type b) { \ + if (likely((int32_t)a == a && (int32_t)b == b)) { \ + int32_t result_one = a operator b; \ + int64_t result_two = a operator b; \ + if (likely(result_one == result_two)) return INTEGER_VAL(result_two); \ + } \ + return krk_long_coerced_ ## name (a, b); \ + } + +OVERFLOW_CHECKED_INT_OPERATION(add,+) +OVERFLOW_CHECKED_INT_OPERATION(sub,-) +OVERFLOW_CHECKED_INT_OPERATION(mul,*) + #define BASIC_BIN_OP(name,operator) \ KRK_METHOD(int,__ ## name ## __,{ \ - if (likely(IS_INTEGER(argv[1]))) return INTEGER_VAL(self operator AS_INTEGER(argv[1])); \ + if (likely(IS_INTEGER(argv[1]))) return krk_int_op_ ## name(self, AS_INTEGER(argv[1])); \ else if (likely(IS_FLOATING(argv[1]))) return FLOATING_VAL((double)self operator AS_FLOATING(argv[1])); \ return NOTIMPL_VAL(); \ }) \ KRK_METHOD(int,__r ## name ## __,{ \ - if (likely(IS_INTEGER(argv[1]))) return INTEGER_VAL(AS_INTEGER(argv[1]) operator self); \ + if (likely(IS_INTEGER(argv[1]))) return krk_int_op_ ## name(AS_INTEGER(argv[1]), self); \ else if (likely(IS_FLOATING(argv[1]))) return FLOATING_VAL(AS_FLOATING(argv[1]) operator (double)self); \ return NOTIMPL_VAL(); \ }) @@ -87,26 +113,20 @@ BASIC_BIN_OP(mul,*) INT_ONLY_BIN_OP(or,|) INT_ONLY_BIN_OP(xor,^) INT_ONLY_BIN_OP(and,&) -INT_ONLY_BIN_OP(lshift,<<) -INT_ONLY_BIN_OP(rshift,>>) -KRK_METHOD(int,__mod__,{ - METHOD_TAKES_EXACTLY(1); - if (likely(IS_INTEGER(argv[1]))) { - if (unlikely(AS_INTEGER(argv[1]) == 0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "integer modulo by zero"); - return INTEGER_VAL(self % AS_INTEGER(argv[1])); - } - return NOTIMPL_VAL(); -}) +#define DEFER_TO_LONG(name) \ + extern KrkValue krk_long_coerced_ ## name (krk_integer_type a, krk_integer_type b); \ + KRK_METHOD(int,__ ## name ## __,{ \ + if (likely(IS_INTEGER(argv[1]))) return krk_long_coerced_ ## name (self, AS_INTEGER(argv[1])); \ + return NOTIMPL_VAL(); \ + }) \ + KRK_METHOD(int,__r ## name ## __,{ \ + if (likely(IS_INTEGER(argv[1]))) return krk_long_coerced_ ## name (AS_INTEGER(argv[1]), self); \ + return NOTIMPL_VAL(); \ + }) -KRK_METHOD(int,__rmod__,{ - METHOD_TAKES_EXACTLY(1); - if (unlikely(self == 0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "integer modulo by zero"); - if (likely(IS_INTEGER(argv[1]))) { - return INTEGER_VAL(AS_INTEGER(argv[1]) % self); - } - return NOTIMPL_VAL(); -}) +DEFER_TO_LONG(lshift) +DEFER_TO_LONG(rshift) COMPARE_OP(lt, <) COMPARE_OP(gt, >) @@ -144,12 +164,58 @@ KRK_METHOD(int,__rtruediv__,{ #define __builtin_floor floor #endif +/** + * These have been corrected to match the behavior with negatives + * that Python produces, for compatibility, and also because that's + * what our 'long' type does... + */ +static KrkValue _krk_int_div(krk_integer_type a, krk_integer_type b) { + if (unlikely(b == 0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "integer division or modulo by zero"); + if (a == 0) return INTEGER_VAL(0); + int64_t abs_a = a < 0 ? -a : a; + int64_t abs_b = b < 0 ? -b : b; + if ((a < 0) != (b < 0)) { + /* If signs don't match, the result is negative, and rounding down means away from 0... */ + int64_t res = -1 - (abs_a - 1) / abs_b; + return INTEGER_VAL(res); + } + return INTEGER_VAL((abs_a / abs_b)); +} + +static KrkValue _krk_int_mod(krk_integer_type a, krk_integer_type b) { + if (unlikely(b == 0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "integer division or modulo by zero"); + if (a == 0) return INTEGER_VAL(0); + int64_t abs_a = a < 0 ? -a : a; + int64_t abs_b = b < 0 ? -b : b; + int64_t res; + if ((a < 0) != (b < 0)) { + /* If quotient would be negative, then remainder is inverted against the divisor. */ + res = (abs_b - 1 - (abs_a - 1) % abs_b); + } else { + res = abs_a % abs_b; + } + /* Negative divisor always yields negative remainder, except when it's 0... */ + return INTEGER_VAL((b < 0) ? -res : res); + +} + +KRK_METHOD(int,__mod__,{ + METHOD_TAKES_EXACTLY(1); + if (likely(IS_INTEGER(argv[1]))) return _krk_int_mod(self, AS_INTEGER(argv[1])); + return NOTIMPL_VAL(); +}) + +KRK_METHOD(int,__rmod__,{ + METHOD_TAKES_EXACTLY(1); + if (likely(IS_INTEGER(argv[1]))) return _krk_int_mod(AS_INTEGER(argv[1]), self); + return NOTIMPL_VAL(); +}) + + KRK_METHOD(int,__floordiv__,{ METHOD_TAKES_EXACTLY(1); if (likely(IS_INTEGER(argv[1]))) { - krk_integer_type b = AS_INTEGER(argv[1]); - if (unlikely(b == 0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "integer division by zero"); - return INTEGER_VAL(self / b); + return _krk_int_div(self,AS_INTEGER(argv[1])); } else if (likely(IS_FLOATING(argv[1]))) { double b = AS_FLOATING(argv[1]); if (unlikely(b == 0.0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "float division by zero"); @@ -161,7 +227,7 @@ KRK_METHOD(int,__floordiv__,{ KRK_METHOD(int,__rfloordiv__,{ METHOD_TAKES_EXACTLY(1); if (unlikely(self == 0)) return krk_runtimeError(vm.exceptions->zeroDivisionError, "integer division by zero"); - else if (likely(IS_INTEGER(argv[1]))) return INTEGER_VAL(AS_INTEGER(argv[1]) / self); + else if (likely(IS_INTEGER(argv[1]))) return _krk_int_div(AS_INTEGER(argv[1]), self); else if (likely(IS_FLOATING(argv[1]))) return FLOATING_VAL(__builtin_floor(AS_FLOATING(argv[1]) / (double)self)); return NOTIMPL_VAL(); }) diff --git a/src/obj_str.c b/src/obj_str.c index dc5a9ec..97d4eee 100644 --- a/src/obj_str.c +++ b/src/obj_str.c @@ -99,22 +99,8 @@ KRK_METHOD(str,__setitem__,{ /* str.__int__(base=10) */ KRK_METHOD(str,__int__,{ METHOD_TAKES_AT_MOST(1); - int base = (argc < 2 || !IS_INTEGER(argv[1])) ? 10 : (int)AS_INTEGER(argv[1]); - char * start = AS_CSTRING(argv[0]); - - /* These special cases for hexadecimal, binary, octal values. */ - if (start[0] == '0' && (start[1] == 'x' || start[1] == 'X')) { - base = 16; - start += 2; - } else if (start[0] == '0' && (start[1] == 'b' || start[1] == 'B')) { - base = 2; - start += 2; - } else if (start[0] == '0' && (start[1] == 'o' || start[1] == 'O')) { - base = 8; - start += 2; - } - krk_integer_type value = parseStrInt(start, NULL, base); - return INTEGER_VAL(value); + int base = (argc < 2 || !IS_INTEGER(argv[1])) ? 0 : (int)AS_INTEGER(argv[1]); + return krk_parse_int(AS_CSTRING(argv[0]), AS_STRING(argv[0])->length, base); }) /* str.__float__() */ @@ -242,7 +228,7 @@ KRK_METHOD(str,format,{ } else if (counterOffset) { goto _formatSwitchedNumbering; } else { - positionalOffset = parseStrInt(fieldStart,NULL,10); + positionalOffset = strtoul(fieldStart,NULL,10); } if (positionalOffset >= argc - 1) { erroneousIndex = positionalOffset; diff --git a/src/private.h b/src/private.h index bd9a7b6..d078b8d 100644 --- a/src/private.h +++ b/src/private.h @@ -21,6 +21,7 @@ extern void _createAndBind_sliceClass(void); extern void _createAndBind_builtins(void); extern void _createAndBind_type(void); extern void _createAndBind_exceptions(void); +extern void _createAndBind_longClass(void); extern void _createAndBind_gcMod(void); extern void _createAndBind_timeMod(void); extern void _createAndBind_osMod(void); diff --git a/src/scanner.c b/src/scanner.c index 0fd5f5e..419b5bd 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -154,24 +154,24 @@ static KrkToken number(char c) { /* Hexadecimal */ advance(); while (isDigit(peek()) || (peek() >= 'a' && peek() <= 'f') || - (peek() >= 'A' && peek() <= 'F')) advance(); + (peek() >= 'A' && peek() <= 'F') || (peek() == '_')) advance(); return makeToken(TOKEN_NUMBER); } else if (peek() == 'b' || peek() == 'B') { /* Binary */ advance(); - while (peek() == '0' || peek() == '1') advance(); + while (peek() == '0' || peek() == '1' || (peek() == '_')) advance(); return makeToken(TOKEN_NUMBER); } if (peek() == 'o' || peek() == 'O') { /* Octal - must be 0o, none of those silly 0123 things */ advance(); - while (peek() >= '0' && peek() <= '7') advance(); + while ((peek() >= '0' && peek() <= '7') || (peek() == '_')) advance(); return makeToken(TOKEN_NUMBER); } /* Otherwise, decimal and maybe 0.123 floating */ } /* Decimal */ - while (isDigit(peek())) advance(); + while (isDigit(peek()) || peek() == '_') advance(); /* Floating point */ if (peek() == '.' && isDigit(peekNext(1))) { diff --git a/src/vendor/rline.c b/src/vendor/rline.c index 773b0a9..015896a 100644 --- a/src/vendor/rline.c +++ b/src/vendor/rline.c @@ -654,15 +654,15 @@ void paint_krk_string(struct syntax_state * state, int type, int isFormat) { int paint_krk_numeral(struct syntax_state * state) { if (charat() == '0' && (nextchar() == 'x' || nextchar() == 'X')) { paint(2, FLAG_NUMERAL); - while (isxdigit(charat())) paint(1, FLAG_NUMERAL); + while (isxdigit(charat()) || charat() == '_') paint(1, FLAG_NUMERAL); } else if (charat() == '0' && (nextchar() == 'o' || nextchar() == 'O')) { paint(2, FLAG_NUMERAL); - while (charat() >= '0' && charat() <= '7') paint(1, FLAG_NUMERAL); + while ((charat() >= '0' && charat() <= '7') || charat() == '_') paint(1, FLAG_NUMERAL); } else if (charat() == '0' && (nextchar() == 'b' || nextchar() == 'B')) { paint(2, FLAG_NUMERAL); - while (charat() == '0' || charat() == '1') paint(1, FLAG_NUMERAL); + while (charat() == '0' || charat() == '1' || charat() == '_') paint(1, FLAG_NUMERAL); } else { - while (isdigit(charat())) paint(1, FLAG_NUMERAL); + while (isdigit(charat()) || charat() == '_') paint(1, FLAG_NUMERAL); if (charat() == '.' && isdigit(nextchar())) { paint(1, FLAG_NUMERAL); while (isdigit(charat())) paint(1, FLAG_NUMERAL); diff --git a/src/vm.c b/src/vm.c index bb3e266..186157c 100644 --- a/src/vm.c +++ b/src/vm.c @@ -1341,6 +1341,7 @@ void krk_initVM(int flags) { _createAndBind_sliceClass(); _createAndBind_exceptions(); _createAndBind_generatorClass(); + _createAndBind_longClass(); _createAndBind_gcMod(); _createAndBind_timeMod(); _createAndBind_osMod(); @@ -2253,9 +2254,12 @@ KrkValue krk_valueSetAttribute(KrkValue owner, char * name, KrkValue to) { a = krk_operator_i ## op (a,b); \ krk_currentThread.stackTop[-2] = a; krk_pop(); break; } +extern KrkValue krk_int_op_add(krk_integer_type a, krk_integer_type b); +extern KrkValue krk_int_op_sub(krk_integer_type a, krk_integer_type b); + /* These operations are most likely to occur on integers, so we special case them */ -#define LIKELY_INT_BINARY_OP(op,operator) { KrkValue b = krk_peek(0); KrkValue a = krk_peek(1); \ - if (likely(IS_INTEGER(a) && IS_INTEGER(b))) a = INTEGER_VAL(AS_INTEGER(a) operator AS_INTEGER(b)); \ +#define LIKELY_INT_BINARY_OP(op) { KrkValue b = krk_peek(0); KrkValue a = krk_peek(1); \ + if (likely(IS_INTEGER(a) && IS_INTEGER(b))) a = krk_int_op_ ## op (AS_INTEGER(a), AS_INTEGER(b)); \ else a = krk_operator_ ## op (a,b); \ krk_currentThread.stackTop[-2] = a; krk_pop(); break; } @@ -2402,8 +2406,8 @@ _finishReturn: (void)0; case OP_GREATER: LIKELY_INT_COMPARE_OP(gt,>) case OP_LESS_EQUAL: LIKELY_INT_COMPARE_OP(le,<=) case OP_GREATER_EQUAL: LIKELY_INT_COMPARE_OP(ge,>=) - case OP_ADD: LIKELY_INT_BINARY_OP(add,+) - case OP_SUBTRACT: LIKELY_INT_BINARY_OP(sub,-) + case OP_ADD: LIKELY_INT_BINARY_OP(add) + case OP_SUBTRACT: LIKELY_INT_BINARY_OP(sub) case OP_MULTIPLY: BINARY_OP(mul) case OP_DIVIDE: BINARY_OP(truediv) case OP_FLOORDIV: BINARY_OP(floordiv) @@ -2415,16 +2419,35 @@ _finishReturn: (void)0; case OP_SHIFTRIGHT: BINARY_OP(rshift) case OP_POW: BINARY_OP(pow) case OP_BITNEGATE: { - KrkValue value = krk_pop(); - if (IS_INTEGER(value)) krk_push(INTEGER_VAL(~AS_INTEGER(value))); - else { krk_runtimeError(vm.exceptions->typeError, "Incompatible operand type for %s negation.", "bit"); goto _finishException; } + KrkValue value = krk_peek(0); + if (IS_INTEGER(value)) { + krk_currentThread.stackTop[-1] = INTEGER_VAL(~AS_INTEGER(value)); + } else { + KrkClass * type = krk_getType(krk_peek(0)); + if (likely(type->_invert != NULL)) { + krk_push(krk_callDirect(type->_invert, 1)); + } else { + krk_runtimeError(vm.exceptions->typeError, "Incompatible operand type for %s negation.", "bit"); + goto _finishException; + } + } break; } case OP_NEGATE: { - KrkValue value = krk_pop(); - if (IS_INTEGER(value)) krk_push(INTEGER_VAL(-AS_INTEGER(value))); - else if (IS_FLOATING(value)) krk_push(FLOATING_VAL(-AS_FLOATING(value))); - else { krk_runtimeError(vm.exceptions->typeError, "Incompatible operand type for %s negation.", "prefix"); goto _finishException; } + KrkValue value = krk_peek(0); + if (IS_INTEGER(value)) { + krk_currentThread.stackTop[-1] = INTEGER_VAL(-AS_INTEGER(value)); + } else if (IS_FLOATING(value)) { + krk_currentThread.stackTop[-1] = FLOATING_VAL(-AS_FLOATING(value)); + } else { + KrkClass * type = krk_getType(krk_peek(0)); + if (likely(type->_negate != NULL)) { + krk_push(krk_callDirect(type->_negate, 1)); + } else { + krk_runtimeError(vm.exceptions->typeError, "Incompatible operand type for %s negation.", "prefix"); + goto _finishException; + } + } break; } case OP_NONE: krk_push(NONE_VAL()); break; diff --git a/test/testBigIntegers.krk b/test/testBigIntegers.krk new file mode 100644 index 0000000..7367da6 --- /dev/null +++ b/test/testBigIntegers.krk @@ -0,0 +1,53 @@ +def test(thing, operations=None, numbers=None, printers=None, shifts=None, shiftops=None): + print('hello world') + + operations = [ + ('+', lambda a, b: a + b), + ('-', lambda a, b: a - b), + ('*', lambda a, b: a * b), + ('|', lambda a, b: a | b), + ('^', lambda a, b: a ^ b), + ('&', lambda a, b: a & b), + ('//', lambda a, b: a // b), + ('%', lambda a, b: a % b), + ] + + numbers = [ + 42, 7, 0, -2, -53, -25932, '-30250320993256832943892058390285932532', + '29394294398256832432748937248937198578921421', '0x29589239862', + '0b1000101010101010000101010010101010001001001000101010001010010', + '32932583298439028439285392', '-5392583232948329853251521' + ] + + shifts = [ + 0, 3, 23, 47, 68, 135, 1035, -4 + ] + + shiftops = [ + ('<<', lambda a, b: a << b), + ('>>', lambda a, b: a >> b), + ] + + printers = [ + str, hex, oct, bin + ] + + for a in numbers: + for printer in printers: + print(printer.__name__,printer(thing(a))) + for b in numbers: + for opname, op in operations: + try: + print(a, opname, b, '=', op(thing(a), thing(b))) + except Exception as e: + print(a, opname, b, '=', str(e)) + for shift in shifts: + for opname, op in shiftops: + try: + print(a, opname, shift, '=', op(thing(a), shift)) + except Exception as e: + print(a, opname, shift, '=', str(e)) + + +if __name__ == '__main__': + test(lambda a: int(a,0) if isinstance(a,str) else int(a)) diff --git a/test/testBigIntegers.krk.expect b/test/testBigIntegers.krk.expect new file mode 100644 index 0000000..74782d6 --- /dev/null +++ b/test/testBigIntegers.krk.expect @@ -0,0 +1,1393 @@ +hello world +str 42 +hex 0x2a +oct 0o52 +bin 0b101010 +42 + 42 = 84 +42 - 42 = 0 +42 * 42 = 1764 +42 | 42 = 42 +42 ^ 42 = 0 +42 & 42 = 42 +42 // 42 = 1 +42 % 42 = 0 +42 + 7 = 49 +42 - 7 = 35 +42 * 7 = 294 +42 | 7 = 47 +42 ^ 7 = 45 +42 & 7 = 2 +42 // 7 = 6 +42 % 7 = 0 +42 + 0 = 42 +42 - 0 = 42 +42 * 0 = 0 +42 | 0 = 42 +42 ^ 0 = 42 +42 & 0 = 0 +42 // 0 = integer division or modulo by zero +42 % 0 = integer division or modulo by zero +42 + -2 = 40 +42 - -2 = 44 +42 * -2 = -84 +42 | -2 = -2 +42 ^ -2 = -44 +42 & -2 = 42 +42 // -2 = -21 +42 % -2 = 0 +42 + -53 = -11 +42 - -53 = 95 +42 * -53 = -2226 +42 | -53 = -21 +42 ^ -53 = -31 +42 & -53 = 10 +42 // -53 = -1 +42 % -53 = -11 +42 + -25932 = -25890 +42 - -25932 = 25974 +42 * -25932 = -1089144 +42 | -25932 = -25922 +42 ^ -25932 = -25954 +42 & -25932 = 32 +42 // -25932 = -1 +42 % -25932 = -25890 +42 + -30250320993256832943892058390285932532 = -30250320993256832943892058390285932490 +42 - -30250320993256832943892058390285932532 = 30250320993256832943892058390285932574 +42 * -30250320993256832943892058390285932532 = -1270513481716786983643466452392009166344 +42 | -30250320993256832943892058390285932532 = -30250320993256832943892058390285932498 +42 ^ -30250320993256832943892058390285932532 = -30250320993256832943892058390285932506 +42 & -30250320993256832943892058390285932532 = 8 +42 // -30250320993256832943892058390285932532 = -1 +42 % -30250320993256832943892058390285932532 = -30250320993256832943892058390285932490 +42 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921463 +42 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921379 +42 * 29394294398256832432748937248937198578921421 = 1234560364726786962175455364455362340314699682 +42 | 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921455 +42 ^ 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921447 +42 & 29394294398256832432748937248937198578921421 = 8 +42 // 29394294398256832432748937248937198578921421 = 0 +42 % 29394294398256832432748937248937198578921421 = 42 +42 + 0x29589239862 = 2841274194060 +42 - 0x29589239862 = -2841274193976 +42 * 0x29589239862 = 119333516148756 +42 | 0x29589239862 = 2841274194026 +42 ^ 0x29589239862 = 2841274193992 +42 & 0x29589239862 = 34 +42 // 0x29589239862 = 0 +42 % 0x29589239862 = 42 +42 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553148 +42 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553064 +42 * 0b1000101010101010000101010010101010001001001000101010001010010 = 52457065477469230452 +42 | 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553146 +42 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553144 +42 & 0b1000101010101010000101010010101010001001001000101010001010010 = 2 +42 // 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +42 % 0b1000101010101010000101010010101010001001001000101010001010010 = 42 +42 + 32932583298439028439285392 = 32932583298439028439285434 +42 - 32932583298439028439285392 = -32932583298439028439285350 +42 * 32932583298439028439285392 = 1383168498534439194449986464 +42 | 32932583298439028439285392 = 32932583298439028439285434 +42 ^ 32932583298439028439285392 = 32932583298439028439285434 +42 & 32932583298439028439285392 = 0 +42 // 32932583298439028439285392 = 0 +42 % 32932583298439028439285392 = 42 +42 + -5392583232948329853251521 = -5392583232948329853251479 +42 - -5392583232948329853251521 = 5392583232948329853251563 +42 * -5392583232948329853251521 = -226488495783829853836563882 +42 | -5392583232948329853251521 = -5392583232948329853251521 +42 ^ -5392583232948329853251521 = -5392583232948329853251563 +42 & -5392583232948329853251521 = 42 +42 // -5392583232948329853251521 = -1 +42 % -5392583232948329853251521 = -5392583232948329853251479 +42 << 0 = 42 +42 >> 0 = 42 +42 << 3 = 336 +42 >> 3 = 5 +42 << 23 = 352321536 +42 >> 23 = 0 +42 << 47 = 5910974510923776 +42 >> 47 = 0 +42 << 68 = 12396212017532818685952 +42 >> 68 = 0 +42 << 135 = 1829358004566965179579101889553185904787456 +42 >> 135 = 0 +42 << 1035 = 15463037268831696511924391529090875148688390782070144216031361860863533842085970844823052385364206618392667715491017771052378460754340860200344764593885006282478083120833229581526411721220784031778876383206543856212382369092369287212860110116279795631842757527045375029407302306644271277676718010048957263386771456 +42 >> 1035 = 0 +42 << -4 = negative shift count +42 >> -4 = negative shift count +str 7 +hex 0x7 +oct 0o7 +bin 0b111 +7 + 42 = 49 +7 - 42 = -35 +7 * 42 = 294 +7 | 42 = 47 +7 ^ 42 = 45 +7 & 42 = 2 +7 // 42 = 0 +7 % 42 = 7 +7 + 7 = 14 +7 - 7 = 0 +7 * 7 = 49 +7 | 7 = 7 +7 ^ 7 = 0 +7 & 7 = 7 +7 // 7 = 1 +7 % 7 = 0 +7 + 0 = 7 +7 - 0 = 7 +7 * 0 = 0 +7 | 0 = 7 +7 ^ 0 = 7 +7 & 0 = 0 +7 // 0 = integer division or modulo by zero +7 % 0 = integer division or modulo by zero +7 + -2 = 5 +7 - -2 = 9 +7 * -2 = -14 +7 | -2 = -1 +7 ^ -2 = -7 +7 & -2 = 6 +7 // -2 = -4 +7 % -2 = -1 +7 + -53 = -46 +7 - -53 = 60 +7 * -53 = -371 +7 | -53 = -49 +7 ^ -53 = -52 +7 & -53 = 3 +7 // -53 = -1 +7 % -53 = -46 +7 + -25932 = -25925 +7 - -25932 = 25939 +7 * -25932 = -181524 +7 | -25932 = -25929 +7 ^ -25932 = -25933 +7 & -25932 = 4 +7 // -25932 = -1 +7 % -25932 = -25925 +7 + -30250320993256832943892058390285932532 = -30250320993256832943892058390285932525 +7 - -30250320993256832943892058390285932532 = 30250320993256832943892058390285932539 +7 * -30250320993256832943892058390285932532 = -211752246952797830607244408732001527724 +7 | -30250320993256832943892058390285932532 = -30250320993256832943892058390285932529 +7 ^ -30250320993256832943892058390285932532 = -30250320993256832943892058390285932533 +7 & -30250320993256832943892058390285932532 = 4 +7 // -30250320993256832943892058390285932532 = -1 +7 % -30250320993256832943892058390285932532 = -30250320993256832943892058390285932525 +7 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921428 +7 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921414 +7 * 29394294398256832432748937248937198578921421 = 205760060787797827029242560742560390052449947 +7 | 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921423 +7 ^ 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921418 +7 & 29394294398256832432748937248937198578921421 = 5 +7 // 29394294398256832432748937248937198578921421 = 0 +7 % 29394294398256832432748937248937198578921421 = 7 +7 + 0x29589239862 = 2841274194025 +7 - 0x29589239862 = -2841274194011 +7 * 0x29589239862 = 19888919358126 +7 | 0x29589239862 = 2841274194023 +7 ^ 0x29589239862 = 2841274194021 +7 & 0x29589239862 = 2 +7 // 0x29589239862 = 0 +7 % 0x29589239862 = 7 +7 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553113 +7 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553099 +7 * 0b1000101010101010000101010010101010001001001000101010001010010 = 8742844246244871742 +7 | 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553111 +7 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553109 +7 & 0b1000101010101010000101010010101010001001001000101010001010010 = 2 +7 // 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +7 % 0b1000101010101010000101010010101010001001001000101010001010010 = 7 +7 + 32932583298439028439285392 = 32932583298439028439285399 +7 - 32932583298439028439285392 = -32932583298439028439285385 +7 * 32932583298439028439285392 = 230528083089073199074997744 +7 | 32932583298439028439285392 = 32932583298439028439285399 +7 ^ 32932583298439028439285392 = 32932583298439028439285399 +7 & 32932583298439028439285392 = 0 +7 // 32932583298439028439285392 = 0 +7 % 32932583298439028439285392 = 7 +7 + -5392583232948329853251521 = -5392583232948329853251514 +7 - -5392583232948329853251521 = 5392583232948329853251528 +7 * -5392583232948329853251521 = -37748082630638308972760647 +7 | -5392583232948329853251521 = -5392583232948329853251521 +7 ^ -5392583232948329853251521 = -5392583232948329853251528 +7 & -5392583232948329853251521 = 7 +7 // -5392583232948329853251521 = -1 +7 % -5392583232948329853251521 = -5392583232948329853251514 +7 << 0 = 7 +7 >> 0 = 7 +7 << 3 = 56 +7 >> 3 = 0 +7 << 23 = 58720256 +7 >> 23 = 0 +7 << 47 = 985162418487296 +7 >> 47 = 0 +7 << 68 = 2066035336255469780992 +7 >> 68 = 0 +7 << 135 = 304893000761160863263183648258864317464576 +7 >> 135 = 0 +7 << 1035 = 2577172878138616085320731921515145858114731797011690702671893643477255640347661807470508730894034436398777952581836295175396410125723476700057460765647501047079680520138871596921068620203464005296479397201090642702063728182061547868810018352713299271973792921174229171567883717774045212946119668341492877231128576 +7 >> 1035 = 0 +7 << -4 = negative shift count +7 >> -4 = negative shift count +str 0 +hex 0x0 +oct 0o0 +bin 0b0 +0 + 42 = 42 +0 - 42 = -42 +0 * 42 = 0 +0 | 42 = 42 +0 ^ 42 = 42 +0 & 42 = 0 +0 // 42 = 0 +0 % 42 = 0 +0 + 7 = 7 +0 - 7 = -7 +0 * 7 = 0 +0 | 7 = 7 +0 ^ 7 = 7 +0 & 7 = 0 +0 // 7 = 0 +0 % 7 = 0 +0 + 0 = 0 +0 - 0 = 0 +0 * 0 = 0 +0 | 0 = 0 +0 ^ 0 = 0 +0 & 0 = 0 +0 // 0 = integer division or modulo by zero +0 % 0 = integer division or modulo by zero +0 + -2 = -2 +0 - -2 = 2 +0 * -2 = 0 +0 | -2 = -2 +0 ^ -2 = -2 +0 & -2 = 0 +0 // -2 = 0 +0 % -2 = 0 +0 + -53 = -53 +0 - -53 = 53 +0 * -53 = 0 +0 | -53 = -53 +0 ^ -53 = -53 +0 & -53 = 0 +0 // -53 = 0 +0 % -53 = 0 +0 + -25932 = -25932 +0 - -25932 = 25932 +0 * -25932 = 0 +0 | -25932 = -25932 +0 ^ -25932 = -25932 +0 & -25932 = 0 +0 // -25932 = 0 +0 % -25932 = 0 +0 + -30250320993256832943892058390285932532 = -30250320993256832943892058390285932532 +0 - -30250320993256832943892058390285932532 = 30250320993256832943892058390285932532 +0 * -30250320993256832943892058390285932532 = 0 +0 | -30250320993256832943892058390285932532 = -30250320993256832943892058390285932532 +0 ^ -30250320993256832943892058390285932532 = -30250320993256832943892058390285932532 +0 & -30250320993256832943892058390285932532 = 0 +0 // -30250320993256832943892058390285932532 = 0 +0 % -30250320993256832943892058390285932532 = 0 +0 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921421 +0 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921421 +0 * 29394294398256832432748937248937198578921421 = 0 +0 | 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921421 +0 ^ 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921421 +0 & 29394294398256832432748937248937198578921421 = 0 +0 // 29394294398256832432748937248937198578921421 = 0 +0 % 29394294398256832432748937248937198578921421 = 0 +0 + 0x29589239862 = 2841274194018 +0 - 0x29589239862 = -2841274194018 +0 * 0x29589239862 = 0 +0 | 0x29589239862 = 2841274194018 +0 ^ 0x29589239862 = 2841274194018 +0 & 0x29589239862 = 0 +0 // 0x29589239862 = 0 +0 % 0x29589239862 = 0 +0 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553106 +0 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553106 +0 * 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0 | 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553106 +0 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553106 +0 & 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0 // 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0 % 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0 + 32932583298439028439285392 = 32932583298439028439285392 +0 - 32932583298439028439285392 = -32932583298439028439285392 +0 * 32932583298439028439285392 = 0 +0 | 32932583298439028439285392 = 32932583298439028439285392 +0 ^ 32932583298439028439285392 = 32932583298439028439285392 +0 & 32932583298439028439285392 = 0 +0 // 32932583298439028439285392 = 0 +0 % 32932583298439028439285392 = 0 +0 + -5392583232948329853251521 = -5392583232948329853251521 +0 - -5392583232948329853251521 = 5392583232948329853251521 +0 * -5392583232948329853251521 = 0 +0 | -5392583232948329853251521 = -5392583232948329853251521 +0 ^ -5392583232948329853251521 = -5392583232948329853251521 +0 & -5392583232948329853251521 = 0 +0 // -5392583232948329853251521 = 0 +0 % -5392583232948329853251521 = 0 +0 << 0 = 0 +0 >> 0 = 0 +0 << 3 = 0 +0 >> 3 = 0 +0 << 23 = 0 +0 >> 23 = 0 +0 << 47 = 0 +0 >> 47 = 0 +0 << 68 = 0 +0 >> 68 = 0 +0 << 135 = 0 +0 >> 135 = 0 +0 << 1035 = 0 +0 >> 1035 = 0 +0 << -4 = negative shift count +0 >> -4 = negative shift count +str -2 +hex -0x2 +oct -0o2 +bin -0b10 +-2 + 42 = 40 +-2 - 42 = -44 +-2 * 42 = -84 +-2 | 42 = -2 +-2 ^ 42 = -44 +-2 & 42 = 42 +-2 // 42 = -1 +-2 % 42 = 40 +-2 + 7 = 5 +-2 - 7 = -9 +-2 * 7 = -14 +-2 | 7 = -1 +-2 ^ 7 = -7 +-2 & 7 = 6 +-2 // 7 = -1 +-2 % 7 = 5 +-2 + 0 = -2 +-2 - 0 = -2 +-2 * 0 = 0 +-2 | 0 = -2 +-2 ^ 0 = -2 +-2 & 0 = 0 +-2 // 0 = integer division or modulo by zero +-2 % 0 = integer division or modulo by zero +-2 + -2 = -4 +-2 - -2 = 0 +-2 * -2 = 4 +-2 | -2 = -2 +-2 ^ -2 = 0 +-2 & -2 = -2 +-2 // -2 = 1 +-2 % -2 = 0 +-2 + -53 = -55 +-2 - -53 = 51 +-2 * -53 = 106 +-2 | -53 = -1 +-2 ^ -53 = 53 +-2 & -53 = -54 +-2 // -53 = 0 +-2 % -53 = -2 +-2 + -25932 = -25934 +-2 - -25932 = 25930 +-2 * -25932 = 51864 +-2 | -25932 = -2 +-2 ^ -25932 = 25930 +-2 & -25932 = -25932 +-2 // -25932 = 0 +-2 % -25932 = -2 +-2 + -30250320993256832943892058390285932532 = -30250320993256832943892058390285932534 +-2 - -30250320993256832943892058390285932532 = 30250320993256832943892058390285932530 +-2 * -30250320993256832943892058390285932532 = 60500641986513665887784116780571865064 +-2 | -30250320993256832943892058390285932532 = -2 +-2 ^ -30250320993256832943892058390285932532 = 30250320993256832943892058390285932530 +-2 & -30250320993256832943892058390285932532 = -30250320993256832943892058390285932532 +-2 // -30250320993256832943892058390285932532 = 0 +-2 % -30250320993256832943892058390285932532 = -2 +-2 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921419 +-2 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921423 +-2 * 29394294398256832432748937248937198578921421 = -58788588796513664865497874497874397157842842 +-2 | 29394294398256832432748937248937198578921421 = -1 +-2 ^ 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921421 +-2 & 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921420 +-2 // 29394294398256832432748937248937198578921421 = -1 +-2 % 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921419 +-2 + 0x29589239862 = 2841274194016 +-2 - 0x29589239862 = -2841274194020 +-2 * 0x29589239862 = -5682548388036 +-2 | 0x29589239862 = -2 +-2 ^ 0x29589239862 = -2841274194020 +-2 & 0x29589239862 = 2841274194018 +-2 // 0x29589239862 = -1 +-2 % 0x29589239862 = 2841274194016 +-2 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553104 +-2 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553108 +-2 * 0b1000101010101010000101010010101010001001001000101010001010010 = -2497955498927106212 +-2 | 0b1000101010101010000101010010101010001001001000101010001010010 = -2 +-2 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553108 +-2 & 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553106 +-2 // 0b1000101010101010000101010010101010001001001000101010001010010 = -1 +-2 % 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553104 +-2 + 32932583298439028439285392 = 32932583298439028439285390 +-2 - 32932583298439028439285392 = -32932583298439028439285394 +-2 * 32932583298439028439285392 = -65865166596878056878570784 +-2 | 32932583298439028439285392 = -2 +-2 ^ 32932583298439028439285392 = -32932583298439028439285394 +-2 & 32932583298439028439285392 = 32932583298439028439285392 +-2 // 32932583298439028439285392 = -1 +-2 % 32932583298439028439285392 = 32932583298439028439285390 +-2 + -5392583232948329853251521 = -5392583232948329853251523 +-2 - -5392583232948329853251521 = 5392583232948329853251519 +-2 * -5392583232948329853251521 = 10785166465896659706503042 +-2 | -5392583232948329853251521 = -1 +-2 ^ -5392583232948329853251521 = 5392583232948329853251521 +-2 & -5392583232948329853251521 = -5392583232948329853251522 +-2 // -5392583232948329853251521 = 0 +-2 % -5392583232948329853251521 = -2 +-2 << 0 = -2 +-2 >> 0 = -2 +-2 << 3 = -16 +-2 >> 3 = -1 +-2 << 23 = -16777216 +-2 >> 23 = -1 +-2 << 47 = -281474976710656 +-2 >> 47 = -1 +-2 << 68 = -590295810358705651712 +-2 >> 68 = -1 +-2 << 135 = -87112285931760246646623899502532662132736 +-2 >> 135 = -1 +-2 << 1035 = -736335108039604595805923406147184530889923370574768772191969612422073040099331944991573923112581267542507986451953227192970402893063850485730703075899286013451337291468249027691733891486704001513279827771740183629161065194874727962517148100775228363421083691764065477590823919364012917984605619526140822066036736 +-2 >> 1035 = -1 +-2 << -4 = negative shift count +-2 >> -4 = negative shift count +str -53 +hex -0x35 +oct -0o65 +bin -0b110101 +-53 + 42 = -11 +-53 - 42 = -95 +-53 * 42 = -2226 +-53 | 42 = -21 +-53 ^ 42 = -31 +-53 & 42 = 10 +-53 // 42 = -2 +-53 % 42 = 31 +-53 + 7 = -46 +-53 - 7 = -60 +-53 * 7 = -371 +-53 | 7 = -49 +-53 ^ 7 = -52 +-53 & 7 = 3 +-53 // 7 = -8 +-53 % 7 = 3 +-53 + 0 = -53 +-53 - 0 = -53 +-53 * 0 = 0 +-53 | 0 = -53 +-53 ^ 0 = -53 +-53 & 0 = 0 +-53 // 0 = integer division or modulo by zero +-53 % 0 = integer division or modulo by zero +-53 + -2 = -55 +-53 - -2 = -51 +-53 * -2 = 106 +-53 | -2 = -1 +-53 ^ -2 = 53 +-53 & -2 = -54 +-53 // -2 = 26 +-53 % -2 = -1 +-53 + -53 = -106 +-53 - -53 = 0 +-53 * -53 = 2809 +-53 | -53 = -53 +-53 ^ -53 = 0 +-53 & -53 = -53 +-53 // -53 = 1 +-53 % -53 = 0 +-53 + -25932 = -25985 +-53 - -25932 = 25879 +-53 * -25932 = 1374396 +-53 | -25932 = -1 +-53 ^ -25932 = 25983 +-53 & -25932 = -25984 +-53 // -25932 = 0 +-53 % -25932 = -53 +-53 + -30250320993256832943892058390285932532 = -30250320993256832943892058390285932585 +-53 - -30250320993256832943892058390285932532 = 30250320993256832943892058390285932479 +-53 * -30250320993256832943892058390285932532 = 1603267012642612146026279094685154424196 +-53 | -30250320993256832943892058390285932532 = -49 +-53 ^ -30250320993256832943892058390285932532 = 30250320993256832943892058390285932487 +-53 & -30250320993256832943892058390285932532 = -30250320993256832943892058390285932536 +-53 // -30250320993256832943892058390285932532 = 0 +-53 % -30250320993256832943892058390285932532 = -53 +-53 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921368 +-53 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921474 +-53 * 29394294398256832432748937248937198578921421 = -1557897603107612118935693674193671524682835313 +-53 | 29394294398256832432748937248937198578921421 = -49 +-53 ^ 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578921466 +-53 & 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921417 +-53 // 29394294398256832432748937248937198578921421 = -1 +-53 % 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921368 +-53 + 0x29589239862 = 2841274193965 +-53 - 0x29589239862 = -2841274194071 +-53 * 0x29589239862 = -150587532282954 +-53 | 0x29589239862 = -21 +-53 ^ 0x29589239862 = -2841274194007 +-53 & 0x29589239862 = 2841274193986 +-53 // 0x29589239862 = -1 +-53 % 0x29589239862 = 2841274193965 +-53 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553053 +-53 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553159 +-53 * 0b1000101010101010000101010010101010001001001000101010001010010 = -66195820721568314618 +-53 | 0b1000101010101010000101010010101010001001001000101010001010010 = -37 +-53 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463553127 +-53 & 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553090 +-53 // 0b1000101010101010000101010010101010001001001000101010001010010 = -1 +-53 % 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553053 +-53 + 32932583298439028439285392 = 32932583298439028439285339 +-53 - 32932583298439028439285392 = -32932583298439028439285445 +-53 * 32932583298439028439285392 = -1745426914817268507282125776 +-53 | 32932583298439028439285392 = -37 +-53 ^ 32932583298439028439285392 = -32932583298439028439285413 +-53 & 32932583298439028439285392 = 32932583298439028439285376 +-53 // 32932583298439028439285392 = -1 +-53 % 32932583298439028439285392 = 32932583298439028439285339 +-53 + -5392583232948329853251521 = -5392583232948329853251574 +-53 - -5392583232948329853251521 = 5392583232948329853251468 +-53 * -5392583232948329853251521 = 285806911346261482222330613 +-53 | -5392583232948329853251521 = -1 +-53 ^ -5392583232948329853251521 = 5392583232948329853251572 +-53 & -5392583232948329853251521 = -5392583232948329853251573 +-53 // -5392583232948329853251521 = 0 +-53 % -5392583232948329853251521 = -53 +-53 << 0 = -53 +-53 >> 0 = -53 +-53 << 3 = -424 +-53 >> 3 = -7 +-53 << 23 = -444596224 +-53 >> 23 = -1 +-53 << 47 = -7459086882832384 +-53 >> 47 = -1 +-53 << 68 = -15642838974505699770368 +-53 >> 68 = -1 +-53 << 135 = -2308475577191646536135533336817115546517504 +-53 >> 135 = -1 +-53 << 1035 = -19512880363049521788856970262900390068582969320231372463087194729184935562632296542276708962483403589876461640976760520613715676666192037871863631511331079356460438223908599233830948124397656040101915435951114866172768227664180291006704424670543551630658717831747735156156833863146342326592048917442731784749973504 +-53 >> 1035 = -1 +-53 << -4 = negative shift count +-53 >> -4 = negative shift count +str -25932 +hex -0x654c +oct -0o62514 +bin -0b110010101001100 +-25932 + 42 = -25890 +-25932 - 42 = -25974 +-25932 * 42 = -1089144 +-25932 | 42 = -25922 +-25932 ^ 42 = -25954 +-25932 & 42 = 32 +-25932 // 42 = -618 +-25932 % 42 = 24 +-25932 + 7 = -25925 +-25932 - 7 = -25939 +-25932 * 7 = -181524 +-25932 | 7 = -25929 +-25932 ^ 7 = -25933 +-25932 & 7 = 4 +-25932 // 7 = -3705 +-25932 % 7 = 3 +-25932 + 0 = -25932 +-25932 - 0 = -25932 +-25932 * 0 = 0 +-25932 | 0 = -25932 +-25932 ^ 0 = -25932 +-25932 & 0 = 0 +-25932 // 0 = integer division or modulo by zero +-25932 % 0 = integer division or modulo by zero +-25932 + -2 = -25934 +-25932 - -2 = -25930 +-25932 * -2 = 51864 +-25932 | -2 = -2 +-25932 ^ -2 = 25930 +-25932 & -2 = -25932 +-25932 // -2 = 12966 +-25932 % -2 = 0 +-25932 + -53 = -25985 +-25932 - -53 = -25879 +-25932 * -53 = 1374396 +-25932 | -53 = -1 +-25932 ^ -53 = 25983 +-25932 & -53 = -25984 +-25932 // -53 = 489 +-25932 % -53 = -15 +-25932 + -25932 = -51864 +-25932 - -25932 = 0 +-25932 * -25932 = 672468624 +-25932 | -25932 = -25932 +-25932 ^ -25932 = 0 +-25932 & -25932 = -25932 +-25932 // -25932 = 1 +-25932 % -25932 = 0 +-25932 + -30250320993256832943892058390285932532 = -30250320993256832943892058390285958464 +-25932 - -30250320993256832943892058390285932532 = 30250320993256832943892058390285906600 +-25932 * -30250320993256832943892058390285932532 = 784451323997136191901008858176894802419824 +-25932 | -30250320993256832943892058390285932532 = -17732 +-25932 ^ -30250320993256832943892058390285932532 = 30250320993256832943892058390285923000 +-25932 & -30250320993256832943892058390285932532 = -30250320993256832943892058390285940732 +-25932 // -30250320993256832943892058390285932532 = 0 +-25932 % -30250320993256832943892058390285932532 = -25932 +-25932 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578895489 +-25932 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578947353 +-25932 * 29394294398256832432748937248937198578921421 = -762252842335596178646045440739439433548590289372 +-25932 | 29394294398256832432748937248937198578921421 = -3 +-25932 ^ 29394294398256832432748937248937198578921421 = -29394294398256832432748937248937198578895495 +-25932 & 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578895492 +-25932 // 29394294398256832432748937248937198578921421 = -1 +-25932 % 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578895489 +-25932 + 0x29589239862 = 2841274168086 +-25932 - 0x29589239862 = -2841274219950 +-25932 * 0x29589239862 = -73679922399274776 +-25932 | 0x29589239862 = -25866 +-25932 ^ 0x29589239862 = -2841274219818 +-25932 & 0x29589239862 = 2841274193952 +-25932 // 0x29589239862 = -1 +-25932 % 0x29589239862 = 2841274168086 +-25932 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463527174 +-25932 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463579038 +-25932 * 0b1000101010101010000101010010101010001001001000101010001010010 = -32388490999088859144792 +-25932 | 0b1000101010101010000101010010101010001001001000101010001010010 = -8458 +-25932 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = -1248977749463544090 +-25932 & 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463535632 +-25932 // 0b1000101010101010000101010010101010001001001000101010001010010 = -1 +-25932 % 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463527174 +-25932 + 32932583298439028439285392 = 32932583298439028439259460 +-25932 - 32932583298439028439285392 = -32932583298439028439311324 +-25932 * 32932583298439028439285392 = -854007750095120885487548785344 +-25932 | 32932583298439028439285392 = -332 +-25932 ^ 32932583298439028439285392 = -32932583298439028439260124 +-25932 & 32932583298439028439285392 = 32932583298439028439259792 +-25932 // 32932583298439028439285392 = -1 +-25932 % 32932583298439028439285392 = 32932583298439028439259460 +-25932 + -5392583232948329853251521 = -5392583232948329853277453 +-25932 - -5392583232948329853251521 = 5392583232948329853225589 +-25932 * -5392583232948329853251521 = 139840468396816089754518442572 +-25932 | -5392583232948329853251521 = -25921 +-25932 ^ -5392583232948329853251521 = 5392583232948329853225611 +-25932 & -5392583232948329853251521 = -5392583232948329853251532 +-25932 // -5392583232948329853251521 = 0 +-25932 % -5392583232948329853251521 = -25932 +-25932 << 0 = -25932 +-25932 >> 0 = -25932 +-25932 << 3 = -207456 +-25932 >> 3 = -3242 +-25932 << 23 = -217533382656 +-25932 >> 23 = -1 +-25932 << 47 = -3649604548030365696 +-25932 >> 47 = -1 +-25932 << 68 = -7653775477110977480097792 +-25932 >> 68 = -1 +-25932 << 135 = -1129497899391203358020125480949838497213054976 +-25932 >> 135 = -1 +-25932 << 1035 = -9547321010841513189219602884104394627518746422872451900241077994664599037927937998760747487077728714956158552336025543784054243911465885397984296082110142450410039321177316893051021637016604083621186246888383220935702371316745722761997342274651610960117771147412872982442622938473791494588396462775941898908232318976 +-25932 >> 1035 = -1 +-25932 << -4 = negative shift count +-25932 >> -4 = negative shift count +str -30250320993256832943892058390285932532 +hex -0x16c1fff9a1a7e64e32fe478f394257f4 +oct -0o266037777150323746234313762170747120453764 +bin -0b10110110000011111111111111001101000011010011111100110010011100011001011111110010001111000111100111001010000100101011111110100 +-30250320993256832943892058390285932532 + 42 = -30250320993256832943892058390285932490 +-30250320993256832943892058390285932532 - 42 = -30250320993256832943892058390285932574 +-30250320993256832943892058390285932532 * 42 = -1270513481716786983643466452392009166344 +-30250320993256832943892058390285932532 | 42 = -30250320993256832943892058390285932498 +-30250320993256832943892058390285932532 ^ 42 = -30250320993256832943892058390285932506 +-30250320993256832943892058390285932532 & 42 = 8 +-30250320993256832943892058390285932532 // 42 = -720245737934686498664096628340141251 +-30250320993256832943892058390285932532 % 42 = 10 +-30250320993256832943892058390285932532 + 7 = -30250320993256832943892058390285932525 +-30250320993256832943892058390285932532 - 7 = -30250320993256832943892058390285932539 +-30250320993256832943892058390285932532 * 7 = -211752246952797830607244408732001527724 +-30250320993256832943892058390285932532 | 7 = -30250320993256832943892058390285932529 +-30250320993256832943892058390285932532 ^ 7 = -30250320993256832943892058390285932533 +-30250320993256832943892058390285932532 & 7 = 4 +-30250320993256832943892058390285932532 // 7 = -4321474427608118991984579770040847505 +-30250320993256832943892058390285932532 % 7 = 3 +-30250320993256832943892058390285932532 + 0 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 - 0 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 * 0 = 0 +-30250320993256832943892058390285932532 | 0 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 ^ 0 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 & 0 = 0 +-30250320993256832943892058390285932532 // 0 = integer division or modulo by zero +-30250320993256832943892058390285932532 % 0 = integer division or modulo by zero +-30250320993256832943892058390285932532 + -2 = -30250320993256832943892058390285932534 +-30250320993256832943892058390285932532 - -2 = -30250320993256832943892058390285932530 +-30250320993256832943892058390285932532 * -2 = 60500641986513665887784116780571865064 +-30250320993256832943892058390285932532 | -2 = -2 +-30250320993256832943892058390285932532 ^ -2 = 30250320993256832943892058390285932530 +-30250320993256832943892058390285932532 & -2 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 // -2 = 15125160496628416471946029195142966266 +-30250320993256832943892058390285932532 % -2 = 0 +-30250320993256832943892058390285932532 + -53 = -30250320993256832943892058390285932585 +-30250320993256832943892058390285932532 - -53 = -30250320993256832943892058390285932479 +-30250320993256832943892058390285932532 * -53 = 1603267012642612146026279094685154424196 +-30250320993256832943892058390285932532 | -53 = -49 +-30250320993256832943892058390285932532 ^ -53 = 30250320993256832943892058390285932487 +-30250320993256832943892058390285932532 & -53 = -30250320993256832943892058390285932536 +-30250320993256832943892058390285932532 // -53 = 570760773457676093280982233778979859 +-30250320993256832943892058390285932532 % -53 = -5 +-30250320993256832943892058390285932532 + -25932 = -30250320993256832943892058390285958464 +-30250320993256832943892058390285932532 - -25932 = -30250320993256832943892058390285906600 +-30250320993256832943892058390285932532 * -25932 = 784451323997136191901008858176894802419824 +-30250320993256832943892058390285932532 | -25932 = -17732 +-30250320993256832943892058390285932532 ^ -25932 = 30250320993256832943892058390285923000 +-30250320993256832943892058390285932532 & -25932 = -30250320993256832943892058390285940732 +-30250320993256832943892058390285932532 // -25932 = 1166524795359279382380535955201524 +-30250320993256832943892058390285932532 % -25932 = -12164 +-30250320993256832943892058390285932532 + -30250320993256832943892058390285932532 = -60500641986513665887784116780571865064 +-30250320993256832943892058390285932532 - -30250320993256832943892058390285932532 = 0 +-30250320993256832943892058390285932532 * -30250320993256832943892058390285932532 = 915081920195075064037689813260364925503888214051065532480370844372855931024 +-30250320993256832943892058390285932532 | -30250320993256832943892058390285932532 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 ^ -30250320993256832943892058390285932532 = 0 +-30250320993256832943892058390285932532 & -30250320993256832943892058390285932532 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 // -30250320993256832943892058390285932532 = 1 +-30250320993256832943892058390285932532 % -30250320993256832943892058390285932532 = 0 +-30250320993256832943892058390285932532 + 29394294398256832432748937248937198578921421 = 29394264147935839175915993356878808292988889 +-30250320993256832943892058390285932532 - 29394294398256832432748937248937198578921421 = -29394324648577825689581881140995588864853953 +-30250320993256832943892058390285932532 * 29394294398256832432748937248937198578921421 = -889186840917560383910002580448025158014428086027184429244492661252429993735567972 +-30250320993256832943892058390285932532 | 29394294398256832432748937248937198578921421 = -8642195380147685027087960678087135283 +-30250320993256832943892058390285932532 ^ 29394294398256832432748937248937198578921421 = -29394281432326599471286047532800164467259455 +-30250320993256832943892058390285932532 & 29394294398256832432748937248937198578921421 = 29394272790131219323601020444839486380124172 +-30250320993256832943892058390285932532 // 29394294398256832432748937248937198578921421 = -1 +-30250320993256832943892058390285932532 % 29394294398256832432748937248937198578921421 = 29394264147935839175915993356878808292988889 +-30250320993256832943892058390285932532 + 0x29589239862 = -30250320993256832943892055549011738514 +-30250320993256832943892058390285932532 - 0x29589239862 = -30250320993256832943892061231560126550 +-30250320993256832943892058390285932532 * 0x29589239862 = -85949456398901593235528178418850657435421825993576 +-30250320993256832943892058390285932532 | 0x29589239862 = -30250320993256832943892055619880896402 +-30250320993256832943892058390285932532 ^ 0x29589239862 = -30250320993256832943892055690750054290 +-30250320993256832943892058390285932532 & 0x29589239862 = 70869157888 +-30250320993256832943892058390285932532 // 0x29589239862 = -10646744709449605319972144 +-30250320993256832943892058390285932532 % 0x29589239862 = 51525502060 +-30250320993256832943892058390285932532 + 0b1000101010101010000101010010101010001001001000101010001010010 = -30250320993256832942643080640822379426 +-30250320993256832943892058390285932532 - 0b1000101010101010000101010010101010001001001000101010001010010 = -30250320993256832945141036139749485638 +-30250320993256832943892058390285932532 * 0b1000101010101010000101010010101010001001001000101010001010010 = -37781977834707993643052556354140174875733634721315044392 +-30250320993256832943892058390285932532 | 0b1000101010101010000101010010101010001001001000101010001010010 = -30250320993256832942715419848352072610 +-30250320993256832943892058390285932532 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = -30250320993256832942787759055881765794 +-30250320993256832943892058390285932532 & 0b1000101010101010000101010010101010001001001000101010001010010 = 72339207529693184 +-30250320993256832943892058390285932532 // 0b1000101010101010000101010010101010001001001000101010001010010 = -24220063973317067526 +-30250320993256832943892058390285932532 % 0b1000101010101010000101010010101010001001001000101010001010010 = 362248358203103224 +-30250320993256832943892058390285932532 + 32932583298439028439285392 = -30250320993223900360593619361846647140 +-30250320993256832943892058390285932532 - 32932583298439028439285392 = -30250320993289765527190497418725217924 +-30250320993256832943892058390285932532 * 32932583298439028439285392 = -996221215914949498445947449761119526194805378587303760405172544 +-30250320993256832943892058390285932532 | 32932583298439028439285392 = -30250320993253035900465085524945797476 +-30250320993256832943892058390285932532 ^ 32932583298439028439285392 = -30250320993282171440336551688044947812 +-30250320993256832943892058390285932532 & 32932583298439028439285392 = 29135539871466163099150336 +-30250320993256832943892058390285932532 // 32932583298439028439285392 = -918552933402 +-30250320993256832943892058390285932532 % 32932583298439028439285392 = 30049436656440287961531052 +-30250320993256832943892058390285932532 + -5392583232948329853251521 = -30250320993262225527125006720139184053 +-30250320993256832943892058390285932532 - -5392583232948329853251521 = -30250320993251440360659110060432681011 +-30250320993256832943892058390285932532 * -5392583232948329853251521 = 163127373779541664871004168256892496317554452868422585832381172 +-30250320993256832943892058390285932532 | -5392583232948329853251521 = -5309341939605529581078465 +-30250320993256832943892058390285932532 ^ -5392583232948329853251521 = 30250320993251606843245795660977027123 +-30250320993256832943892058390285932532 & -5392583232948329853251521 = -30250320993256916185185401190558105588 +-30250320993256832943892058390285932532 // -5392583232948329853251521 = 5609615964465 +-30250320993256832943892058390285932532 % -5392583232948329853251521 = -3599808633575499642731267 +-30250320993256832943892058390285932532 << 0 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 >> 0 = -30250320993256832943892058390285932532 +-30250320993256832943892058390285932532 << 3 = -242002567946054663551136467122287460256 +-30250320993256832943892058390285932532 >> 3 = -3781290124157104117986507298785741567 +-30250320993256832943892058390285932532 << 23 = -253758084686602214887796472149219695925395456 +-30250320993256832943892058390285932532 >> 23 = -3606119274289230459200389193331 +-30250320993256832943892058390285932532 << 47 = -4257354198533417665250977177285443069994679450730496 +-30250320993256832943892058390285932532 >> 47 = -214941458361699012470269 +-30250320993256832943892058390285932532 << 68 = -8928318872162753923516417289298521505125481999458361147392 +-30250320993256832943892058390285932532 >> 68 = -102492074185227877 +-30250320993256832943892058390285932532 << 135 = -1317587305946059429711122763288029137539909037081194005931531573475676862283776 +-30250320993256832943892058390285932532 >> 135 = -1 +-30250320993256832943892058390285932532 << 1035 = -11137186688401244546708046543405115060835581043900188744822534802371479693099672715818668914085151276402015170832505741469976464971352741163164058363991600277318077908484176291564762286720618221887468685023964032893767773652179122385271256416982300727986717826578899404113370344659803095301107501048038521381105548576573384855518668919459197564747776 +-30250320993256832943892058390285932532 >> 1035 = -1 +-30250320993256832943892058390285932532 << -4 = negative shift count +-30250320993256832943892058390285932532 >> -4 = negative shift count +str 29394294398256832432748937248937198578921421 +hex 0x1516e114992dcd23e74d446db88e405316fcd +oct 0o1242670212231133464437164650433334216200514267715 +bin 0b1010100010110111000010001010010011001001011011100110100100011111001110100110101000100011011011011100010001110010000000101001100010110111111001101 +29394294398256832432748937248937198578921421 + 42 = 29394294398256832432748937248937198578921463 +29394294398256832432748937248937198578921421 - 42 = 29394294398256832432748937248937198578921379 +29394294398256832432748937248937198578921421 * 42 = 1234560364726786962175455364455362340314699682 +29394294398256832432748937248937198578921421 | 42 = 29394294398256832432748937248937198578921455 +29394294398256832432748937248937198578921421 ^ 42 = 29394294398256832432748937248937198578921447 +29394294398256832432748937248937198578921421 & 42 = 8 +29394294398256832432748937248937198578921421 // 42 = 699864152339448391255927077355647585212414 +29394294398256832432748937248937198578921421 % 42 = 33 +29394294398256832432748937248937198578921421 + 7 = 29394294398256832432748937248937198578921428 +29394294398256832432748937248937198578921421 - 7 = 29394294398256832432748937248937198578921414 +29394294398256832432748937248937198578921421 * 7 = 205760060787797827029242560742560390052449947 +29394294398256832432748937248937198578921421 | 7 = 29394294398256832432748937248937198578921423 +29394294398256832432748937248937198578921421 ^ 7 = 29394294398256832432748937248937198578921418 +29394294398256832432748937248937198578921421 & 7 = 5 +29394294398256832432748937248937198578921421 // 7 = 4199184914036690347535562464133885511274488 +29394294398256832432748937248937198578921421 % 7 = 5 +29394294398256832432748937248937198578921421 + 0 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 - 0 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 * 0 = 0 +29394294398256832432748937248937198578921421 | 0 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 ^ 0 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 & 0 = 0 +29394294398256832432748937248937198578921421 // 0 = integer division or modulo by zero +29394294398256832432748937248937198578921421 % 0 = integer division or modulo by zero +29394294398256832432748937248937198578921421 + -2 = 29394294398256832432748937248937198578921419 +29394294398256832432748937248937198578921421 - -2 = 29394294398256832432748937248937198578921423 +29394294398256832432748937248937198578921421 * -2 = -58788588796513664865497874497874397157842842 +29394294398256832432748937248937198578921421 | -2 = -1 +29394294398256832432748937248937198578921421 ^ -2 = -29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 & -2 = 29394294398256832432748937248937198578921420 +29394294398256832432748937248937198578921421 // -2 = -14697147199128416216374468624468599289460711 +29394294398256832432748937248937198578921421 % -2 = -1 +29394294398256832432748937248937198578921421 + -53 = 29394294398256832432748937248937198578921368 +29394294398256832432748937248937198578921421 - -53 = 29394294398256832432748937248937198578921474 +29394294398256832432748937248937198578921421 * -53 = -1557897603107612118935693674193671524682835313 +29394294398256832432748937248937198578921421 | -53 = -49 +29394294398256832432748937248937198578921421 ^ -53 = -29394294398256832432748937248937198578921466 +29394294398256832432748937248937198578921421 & -53 = 29394294398256832432748937248937198578921417 +29394294398256832432748937248937198578921421 // -53 = -554609328268996838353753532998815067526820 +29394294398256832432748937248937198578921421 % -53 = -39 +29394294398256832432748937248937198578921421 + -25932 = 29394294398256832432748937248937198578895489 +29394294398256832432748937248937198578921421 - -25932 = 29394294398256832432748937248937198578947353 +29394294398256832432748937248937198578921421 * -25932 = -762252842335596178646045440739439433548590289372 +29394294398256832432748937248937198578921421 | -25932 = -3 +29394294398256832432748937248937198578921421 ^ -25932 = -29394294398256832432748937248937198578895495 +29394294398256832432748937248937198578921421 & -25932 = 29394294398256832432748937248937198578895492 +29394294398256832432748937248937198578921421 // -25932 = -1133514360568287537897151675495033108859 +29394294398256832432748937248937198578921421 % -25932 = -10167 +29394294398256832432748937248937198578921421 + -30250320993256832943892058390285932532 = 29394264147935839175915993356878808292988889 +29394294398256832432748937248937198578921421 - -30250320993256832943892058390285932532 = 29394324648577825689581881140995588864853953 +29394294398256832432748937248937198578921421 * -30250320993256832943892058390285932532 = -889186840917560383910002580448025158014428086027184429244492661252429993735567972 +29394294398256832432748937248937198578921421 | -30250320993256832943892058390285932532 = -8642195380147685027087960678087135283 +29394294398256832432748937248937198578921421 ^ -30250320993256832943892058390285932532 = -29394281432326599471286047532800164467259455 +29394294398256832432748937248937198578921421 & -30250320993256832943892058390285932532 = 29394272790131219323601020444839486380124172 +29394294398256832432748937248937198578921421 // -30250320993256832943892058390285932532 = -971702 +29394294398256832432748937248937198578921421 % -30250320993256832943892058390285932532 = -3011532818652496863673020422634288043 +29394294398256832432748937248937198578921421 + 29394294398256832432748937248937198578921421 = 58788588796513664865497874497874397157842842 +29394294398256832432748937248937198578921421 - 29394294398256832432748937248937198578921421 = 0 +29394294398256832432748937248937198578921421 * 29394294398256832432748937248937198578921421 = 864024543171392998682419558732288192659087739620427400338583924880311146986727692659241 +29394294398256832432748937248937198578921421 | 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 ^ 29394294398256832432748937248937198578921421 = 0 +29394294398256832432748937248937198578921421 & 29394294398256832432748937248937198578921421 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 // 29394294398256832432748937248937198578921421 = 1 +29394294398256832432748937248937198578921421 % 29394294398256832432748937248937198578921421 = 0 +29394294398256832432748937248937198578921421 + 0x29589239862 = 29394294398256832432748937248940039853115439 +29394294398256832432748937248937198578921421 - 0x29589239862 = 29394294398256832432748937248934357304727403 +29394294398256832432748937248937198578921421 * 0x29589239862 = 83517250125134993874520418870120097119423775415530259578 +29394294398256832432748937248937198578921421 | 0x29589239862 = 29394294398256832432748937248939472898490351 +29394294398256832432748937248937198578921421 ^ 0x29589239862 = 29394294398256832432748937248938905943865263 +29394294398256832432748937248937198578921421 & 0x29589239862 = 566954625088 +29394294398256832432748937248937198578921421 // 0x29589239862 = 10345462067738265642210541425618 +29394294398256832432748937248937198578921421 % 0x29589239862 = 1014931368297 +29394294398256832432748937248937198578921421 + 0b1000101010101010000101010010101010001001001000101010001010010 = 29394294398256832432748938497914948042474527 +29394294398256832432748937248937198578921421 - 0b1000101010101010000101010010101010001001001000101010001010010 = 29394294398256832432748935999959449115368315 +29394294398256832432748937248937198578921421 * 0b1000101010101010000101010010101010001001001000101010001010010 = 36712819664603944562715317187242140903411208848659139834483626 +29394294398256832432748937248937198578921421 | 0b1000101010101010000101010010101010001001001000101010001010010 = 29394294398256832432748938475114770535383007 +29394294398256832432748937248937198578921421 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 29394294398256832432748938452314593028291487 +29394294398256832432748937248937198578921421 & 0b1000101010101010000101010010101010001001001000101010001010010 = 22800177507091520 +29394294398256832432748937248937198578921421 // 0b1000101010101010000101010010101010001001001000101010001010010 = 23534682191802007358272184 +29394294398256832432748937248937198578921421 % 0b1000101010101010000101010010101010001001001000101010001010010 = 99341456892317917 +29394294398256832432748937248937198578921421 + 32932583298439028439285392 = 29394294398256832465681520547376227018206813 +29394294398256832432748937248937198578921421 - 32932583298439028439285392 = 29394294398256832399816353950498170139636029 +29394294398256832432748937248937198578921421 * 32932583298439028439285392 = 968030048769432851282694397002540906492053861479512032742127361182032 +29394294398256832432748937248937198578921421 | 32932583298439028439285392 = 29394294398256832434001151244850490827702237 +29394294398256832432748937248937198578921421 ^ 32932583298439028439285392 = 29394294398256832402320781942324754637197661 +29394294398256832432748937248937198578921421 & 32932583298439028439285392 = 31680369302525736190504576 +29394294398256832432748937248937198578921421 // 32932583298439028439285392 = 892559631046316753 +29394294398256832432748937248937198578921421 % 32932583298439028439285392 = 6696136095944489581149245 +29394294398256832432748937248937198578921421 + -5392583232948329853251521 = 29394294398256832427356354015988868725669900 +29394294398256832432748937248937198578921421 - -5392583232948329853251521 = 29394294398256832438141520481885528432172942 +29394294398256832432748937248937198578921421 * -5392583232948329853251521 = -158511179116386811499406594352977335675254166910582965199250007731341 +29394294398256832432748937248937198578921421 | -5392583232948329853251521 = -5469532876153509380097 +29394294398256832432748937248937198578921421 ^ -5392583232948329853251521 = -29394294398256832427367293081741175744430094 +29394294398256832432748937248937198578921421 & -5392583232948329853251521 = 29394294398256832427361823548865022235049997 +29394294398256832432748937248937198578921421 // -5392583232948329853251521 = -5450874493444926661 +29394294398256832432748937248937198578921421 % -5392583232948329853251521 = -3290497270550473652779960 +29394294398256832432748937248937198578921421 << 0 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 >> 0 = 29394294398256832432748937248937198578921421 +29394294398256832432748937248937198578921421 << 3 = 235154355186054659461991497991497588631371368 +29394294398256832432748937248937198578921421 >> 3 = 3674286799782104054093617156117149822365177 +29394294398256832432748937248937198578921421 << 23 = 246577213143572450600017196997932575496728863571968 +29394294398256832432748937248937198578921421 >> 23 = 3504072952062706045240037113301420042 +29394294398256832432748937248937198578921421 << 47 = 4136879165587754015365818117748866372544927437581438681088 +29394294398256832432748937248937198578921421 >> 47 = 208859023574751975848676986295 +29394294398256832432748937248937198578921421 << 68 = 8675664415870689508832456197273270610915339665578789292921061376 +29394294398256832432748937248937198578921421 >> 68 = 99591743266464221882189 +29394294398256832432748937248937198578921421 << 135 = 1280302089191643844301065090360873111770016760291020960020862234501702887262207868928 +29394294398256832432748937248937198578921421 >> 135 = 674 +29394294398256832432748937248937198578921421 << 1035 = 10822025470744194434874685931649766843036073341855818628074561706281209989058818925410559174044284280393266793608718841637470282639774886521695054366266407828676307489721147021966403130455074595277110600416489238554865820074515036367234076149638311183434348650390023390984520750629139727539662956474484572486989113369529269129909343072089690741935521660928 +29394294398256832432748937248937198578921421 >> 1035 = 0 +29394294398256832432748937248937198578921421 << -4 = negative shift count +29394294398256832432748937248937198578921421 >> -4 = negative shift count +str 2841274194018 +hex 0x29589239862 +oct 0o51261110714142 +bin 0b101001010110001001001000111001100001100010 +0x29589239862 + 42 = 2841274194060 +0x29589239862 - 42 = 2841274193976 +0x29589239862 * 42 = 119333516148756 +0x29589239862 | 42 = 2841274194026 +0x29589239862 ^ 42 = 2841274193992 +0x29589239862 & 42 = 34 +0x29589239862 // 42 = 67649385571 +0x29589239862 % 42 = 36 +0x29589239862 + 7 = 2841274194025 +0x29589239862 - 7 = 2841274194011 +0x29589239862 * 7 = 19888919358126 +0x29589239862 | 7 = 2841274194023 +0x29589239862 ^ 7 = 2841274194021 +0x29589239862 & 7 = 2 +0x29589239862 // 7 = 405896313431 +0x29589239862 % 7 = 1 +0x29589239862 + 0 = 2841274194018 +0x29589239862 - 0 = 2841274194018 +0x29589239862 * 0 = 0 +0x29589239862 | 0 = 2841274194018 +0x29589239862 ^ 0 = 2841274194018 +0x29589239862 & 0 = 0 +0x29589239862 // 0 = integer division or modulo by zero +0x29589239862 % 0 = integer division or modulo by zero +0x29589239862 + -2 = 2841274194016 +0x29589239862 - -2 = 2841274194020 +0x29589239862 * -2 = -5682548388036 +0x29589239862 | -2 = -2 +0x29589239862 ^ -2 = -2841274194020 +0x29589239862 & -2 = 2841274194018 +0x29589239862 // -2 = -1420637097009 +0x29589239862 % -2 = 0 +0x29589239862 + -53 = 2841274193965 +0x29589239862 - -53 = 2841274194071 +0x29589239862 * -53 = -150587532282954 +0x29589239862 | -53 = -21 +0x29589239862 ^ -53 = -2841274194007 +0x29589239862 & -53 = 2841274193986 +0x29589239862 // -53 = -53608947057 +0x29589239862 % -53 = -3 +0x29589239862 + -25932 = 2841274168086 +0x29589239862 - -25932 = 2841274219950 +0x29589239862 * -25932 = -73679922399274776 +0x29589239862 | -25932 = -25866 +0x29589239862 ^ -25932 = -2841274219818 +0x29589239862 & -25932 = 2841274193952 +0x29589239862 // -25932 = -109566335 +0x29589239862 % -25932 = -5202 +0x29589239862 + -30250320993256832943892058390285932532 = -30250320993256832943892055549011738514 +0x29589239862 - -30250320993256832943892058390285932532 = 30250320993256832943892061231560126550 +0x29589239862 * -30250320993256832943892058390285932532 = -85949456398901593235528178418850657435421825993576 +0x29589239862 | -30250320993256832943892058390285932532 = -30250320993256832943892055619880896402 +0x29589239862 ^ -30250320993256832943892058390285932532 = -30250320993256832943892055690750054290 +0x29589239862 & -30250320993256832943892058390285932532 = 70869157888 +0x29589239862 // -30250320993256832943892058390285932532 = -1 +0x29589239862 % -30250320993256832943892058390285932532 = -30250320993256832943892055549011738514 +0x29589239862 + 29394294398256832432748937248937198578921421 = 29394294398256832432748937248940039853115439 +0x29589239862 - 29394294398256832432748937248937198578921421 = -29394294398256832432748937248934357304727403 +0x29589239862 * 29394294398256832432748937248937198578921421 = 83517250125134993874520418870120097119423775415530259578 +0x29589239862 | 29394294398256832432748937248937198578921421 = 29394294398256832432748937248939472898490351 +0x29589239862 ^ 29394294398256832432748937248937198578921421 = 29394294398256832432748937248938905943865263 +0x29589239862 & 29394294398256832432748937248937198578921421 = 566954625088 +0x29589239862 // 29394294398256832432748937248937198578921421 = 0 +0x29589239862 % 29394294398256832432748937248937198578921421 = 2841274194018 +0x29589239862 + 0x29589239862 = 5682548388036 +0x29589239862 - 0x29589239862 = 0 +0x29589239862 * 0x29589239862 = 8072839045592635506984324 +0x29589239862 | 0x29589239862 = 2841274194018 +0x29589239862 ^ 0x29589239862 = 0 +0x29589239862 & 0x29589239862 = 2841274194018 +0x29589239862 // 0x29589239862 = 1 +0x29589239862 % 0x29589239862 = 0 +0x29589239862 + 0b1000101010101010000101010010101010001001001000101010001010010 = 1248980590737747124 +0x29589239862 - 0b1000101010101010000101010010101010001001001000101010001010010 = -1248974908189359088 +0x29589239862 * 0b1000101010101010000101010010101010001001001000101010001010010 = 3548688248453472383116690519908 +0x29589239862 | 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977820464962674 +0x29589239862 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 1248975050192178224 +0x29589239862 & 0b1000101010101010000101010010101010001001001000101010001010010 = 2770272784450 +0x29589239862 // 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0x29589239862 % 0b1000101010101010000101010010101010001001001000101010001010010 = 2841274194018 +0x29589239862 + 32932583298439028439285392 = 32932583298441869713479410 +0x29589239862 - 32932583298439028439285392 = -32932583298436187165091374 +0x29589239862 * 32932583298439028439285392 = 93570499068202998486345582602681185056 +0x29589239862 | 32932583298439028439285392 = 32932583298441313378893554 +0x29589239862 ^ 32932583298439028439285392 = 32932583298440757044307698 +0x29589239862 & 32932583298439028439285392 = 556334585856 +0x29589239862 // 32932583298439028439285392 = 0 +0x29589239862 % 32932583298439028439285392 = 2841274194018 +0x29589239862 + -5392583232948329853251521 = -5392583232945488579057503 +0x29589239862 - -5392583232948329853251521 = 5392583232951171127445539 +0x29589239862 * -5392583232948329853251521 = -15321807578870246645636423545907601378 +0x29589239862 | -5392583232948329853251521 = -5392583232948327703668609 +0x29589239862 ^ -5392583232948329853251521 = -5392583232951166828279715 +0x29589239862 & -5392583232948329853251521 = 2839124611106 +0x29589239862 // -5392583232948329853251521 = -1 +0x29589239862 % -5392583232948329853251521 = -5392583232945488579057503 +0x29589239862 << 0 = 2841274194018 +0x29589239862 >> 0 = 2841274194018 +0x29589239862 << 3 = 22730193552144 +0x29589239862 >> 3 = 355159274252 +0x29589239862 << 23 = 23834335434132946944 +0x29589239862 >> 23 = 338706 +0x29589239862 << 47 = 399873793794902223596027904 +0x29589239862 >> 47 = 0 +0x29589239862 << 68 = 838596126404566788018857110929408 +0x29589239862 >> 68 = 0 +0x29589239862 << 135 = 123754944999913827469449603659917360375454693666586624 +0x29589239862 >> 135 = 0 +0x29589239862 << 1035 = 1046064970311192249985941844475541497342092224503804040308226955853236708920478183333087255096482821406182101380300734537270511017659363615728080595886108674205304334640358201996271687747409791831489797487924471559123961856537022398088958642267038204629566379732534542228423235941770813350425334275364663648823238324989722624 +0x29589239862 >> 1035 = 0 +0x29589239862 << -4 = negative shift count +0x29589239862 >> -4 = negative shift count +str 1248977749463553106 +hex 0x115542a551245452 +oct 0o105252052252111052122 +bin 0b1000101010101010000101010010101010001001001000101010001010010 +0b1000101010101010000101010010101010001001001000101010001010010 + 42 = 1248977749463553148 +0b1000101010101010000101010010101010001001001000101010001010010 - 42 = 1248977749463553064 +0b1000101010101010000101010010101010001001001000101010001010010 * 42 = 52457065477469230452 +0b1000101010101010000101010010101010001001001000101010001010010 | 42 = 1248977749463553146 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 42 = 1248977749463553144 +0b1000101010101010000101010010101010001001001000101010001010010 & 42 = 2 +0b1000101010101010000101010010101010001001001000101010001010010 // 42 = 29737565463417931 +0b1000101010101010000101010010101010001001001000101010001010010 % 42 = 4 +0b1000101010101010000101010010101010001001001000101010001010010 + 7 = 1248977749463553113 +0b1000101010101010000101010010101010001001001000101010001010010 - 7 = 1248977749463553099 +0b1000101010101010000101010010101010001001001000101010001010010 * 7 = 8742844246244871742 +0b1000101010101010000101010010101010001001001000101010001010010 | 7 = 1248977749463553111 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 7 = 1248977749463553109 +0b1000101010101010000101010010101010001001001000101010001010010 & 7 = 2 +0b1000101010101010000101010010101010001001001000101010001010010 // 7 = 178425392780507586 +0b1000101010101010000101010010101010001001001000101010001010010 % 7 = 4 +0b1000101010101010000101010010101010001001001000101010001010010 + 0 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 - 0 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 * 0 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 | 0 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 0 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 & 0 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 // 0 = integer division or modulo by zero +0b1000101010101010000101010010101010001001001000101010001010010 % 0 = integer division or modulo by zero +0b1000101010101010000101010010101010001001001000101010001010010 + -2 = 1248977749463553104 +0b1000101010101010000101010010101010001001001000101010001010010 - -2 = 1248977749463553108 +0b1000101010101010000101010010101010001001001000101010001010010 * -2 = -2497955498927106212 +0b1000101010101010000101010010101010001001001000101010001010010 | -2 = -2 +0b1000101010101010000101010010101010001001001000101010001010010 ^ -2 = -1248977749463553108 +0b1000101010101010000101010010101010001001001000101010001010010 & -2 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 // -2 = -624488874731776553 +0b1000101010101010000101010010101010001001001000101010001010010 % -2 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 + -53 = 1248977749463553053 +0b1000101010101010000101010010101010001001001000101010001010010 - -53 = 1248977749463553159 +0b1000101010101010000101010010101010001001001000101010001010010 * -53 = -66195820721568314618 +0b1000101010101010000101010010101010001001001000101010001010010 | -53 = -37 +0b1000101010101010000101010010101010001001001000101010001010010 ^ -53 = -1248977749463553127 +0b1000101010101010000101010010101010001001001000101010001010010 & -53 = 1248977749463553090 +0b1000101010101010000101010010101010001001001000101010001010010 // -53 = -23565617914406663 +0b1000101010101010000101010010101010001001001000101010001010010 % -53 = -33 +0b1000101010101010000101010010101010001001001000101010001010010 + -25932 = 1248977749463527174 +0b1000101010101010000101010010101010001001001000101010001010010 - -25932 = 1248977749463579038 +0b1000101010101010000101010010101010001001001000101010001010010 * -25932 = -32388490999088859144792 +0b1000101010101010000101010010101010001001001000101010001010010 | -25932 = -8458 +0b1000101010101010000101010010101010001001001000101010001010010 ^ -25932 = -1248977749463544090 +0b1000101010101010000101010010101010001001001000101010001010010 & -25932 = 1248977749463535632 +0b1000101010101010000101010010101010001001001000101010001010010 // -25932 = -48163572013866 +0b1000101010101010000101010010101010001001001000101010001010010 % -25932 = -20006 +0b1000101010101010000101010010101010001001001000101010001010010 + -30250320993256832943892058390285932532 = -30250320993256832942643080640822379426 +0b1000101010101010000101010010101010001001001000101010001010010 - -30250320993256832943892058390285932532 = 30250320993256832945141036139749485638 +0b1000101010101010000101010010101010001001001000101010001010010 * -30250320993256832943892058390285932532 = -37781977834707993643052556354140174875733634721315044392 +0b1000101010101010000101010010101010001001001000101010001010010 | -30250320993256832943892058390285932532 = -30250320993256832942715419848352072610 +0b1000101010101010000101010010101010001001001000101010001010010 ^ -30250320993256832943892058390285932532 = -30250320993256832942787759055881765794 +0b1000101010101010000101010010101010001001001000101010001010010 & -30250320993256832943892058390285932532 = 72339207529693184 +0b1000101010101010000101010010101010001001001000101010001010010 // -30250320993256832943892058390285932532 = -1 +0b1000101010101010000101010010101010001001001000101010001010010 % -30250320993256832943892058390285932532 = -30250320993256832942643080640822379426 +0b1000101010101010000101010010101010001001001000101010001010010 + 29394294398256832432748937248937198578921421 = 29394294398256832432748938497914948042474527 +0b1000101010101010000101010010101010001001001000101010001010010 - 29394294398256832432748937248937198578921421 = -29394294398256832432748935999959449115368315 +0b1000101010101010000101010010101010001001001000101010001010010 * 29394294398256832432748937248937198578921421 = 36712819664603944562715317187242140903411208848659139834483626 +0b1000101010101010000101010010101010001001001000101010001010010 | 29394294398256832432748937248937198578921421 = 29394294398256832432748938475114770535383007 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 29394294398256832432748937248937198578921421 = 29394294398256832432748938452314593028291487 +0b1000101010101010000101010010101010001001001000101010001010010 & 29394294398256832432748937248937198578921421 = 22800177507091520 +0b1000101010101010000101010010101010001001001000101010001010010 // 29394294398256832432748937248937198578921421 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 % 29394294398256832432748937248937198578921421 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 + 0x29589239862 = 1248980590737747124 +0b1000101010101010000101010010101010001001001000101010001010010 - 0x29589239862 = 1248974908189359088 +0b1000101010101010000101010010101010001001001000101010001010010 * 0x29589239862 = 3548688248453472383116690519908 +0b1000101010101010000101010010101010001001001000101010001010010 | 0x29589239862 = 1248977820464962674 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 0x29589239862 = 1248975050192178224 +0b1000101010101010000101010010101010001001001000101010001010010 & 0x29589239862 = 2770272784450 +0b1000101010101010000101010010101010001001001000101010001010010 // 0x29589239862 = 439583 +0b1000101010101010000101010010101010001001001000101010001010010 % 0x29589239862 = 1915434538612 +0b1000101010101010000101010010101010001001001000101010001010010 + 0b1000101010101010000101010010101010001001001000101010001010010 = 2497955498927106212 +0b1000101010101010000101010010101010001001001000101010001010010 - 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 * 0b1000101010101010000101010010101010001001001000101010001010010 = 1559945418655042030962558270082247236 +0b1000101010101010000101010010101010001001001000101010001010010 | 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 & 0b1000101010101010000101010010101010001001001000101010001010010 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 // 0b1000101010101010000101010010101010001001001000101010001010010 = 1 +0b1000101010101010000101010010101010001001001000101010001010010 % 0b1000101010101010000101010010101010001001001000101010001010010 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 + 32932583298439028439285392 = 32932584547416777902838498 +0b1000101010101010000101010010101010001001001000101010001010010 - 32932583298439028439285392 = -32932582049461278975732286 +0b1000101010101010000101010010101010001001001000101010001010010 * 32932583298439028439285392 = 41132063772105374230440788653395683882027552 +0b1000101010101010000101010010101010001001001000101010001010010 | 32932583298439028439285392 = 32932584524898087200390866 +0b1000101010101010000101010010101010001001001000101010001010010 ^ 32932583298439028439285392 = 32932584502379396497943234 +0b1000101010101010000101010010101010001001001000101010001010010 & 32932583298439028439285392 = 22518690702447632 +0b1000101010101010000101010010101010001001001000101010001010010 // 32932583298439028439285392 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 % 32932583298439028439285392 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 + -5392583232948329853251521 = -5392581983970580389698415 +0b1000101010101010000101010010101010001001001000101010001010010 - -5392583232948329853251521 = 5392584481926079316804627 +0b1000101010101010000101010010101010001001001000101010001010010 * -5392583232948329853251521 = -6735216470082696360420304870393495758774226 +0b1000101010101010000101010010101010001001001000101010001010010 | -5392583232948329853251521 = -5392583136894992706448257 +0b1000101010101010000101010010101010001001001000101010001010010 ^ -5392583232948329853251521 = -5392584289819405023198099 +0b1000101010101010000101010010101010001001001000101010001010010 & -5392583232948329853251521 = 1152924412316749842 +0b1000101010101010000101010010101010001001001000101010001010010 // -5392583232948329853251521 = -1 +0b1000101010101010000101010010101010001001001000101010001010010 % -5392583232948329853251521 = -5392581983970580389698415 +0b1000101010101010000101010010101010001001001000101010001010010 << 0 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 >> 0 = 1248977749463553106 +0b1000101010101010000101010010101010001001001000101010001010010 << 3 = 9991821995708424848 +0b1000101010101010000101010010101010001001001000101010001010010 >> 3 = 156122218682944138 +0b1000101010101010000101010010101010001001001000101010001010010 << 23 = 10477184740971957293416448 +0b1000101010101010000101010010101010001001001000101010001010010 >> 23 = 148889750178 +0b1000101010101010000101010010101010001001001000101010001010010 << 47 = 175777991471190577454423126048768 +0b1000101010101010000101010010101010001001001000101010001010010 >> 47 = 8874 +0b1000101010101010000101010010101010001001001000101010001010010 << 68 = 368633166369790261889698367639425908736 +0b1000101010101010000101010010101010001001001000101010001010010 >> 68 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 << 135 = 54400653416837725589406341415322028588876509444671178539008 +0b1000101010101010000101010010101010001001001000101010001010010 >> 135 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 << 1035 = 459833083045153788654170669036916833098072170306072229909871535990358582816359244878137847041058030501125310490014801251185300330513533660045811948452071243092251373027747878445797299432028541581738715250782652386365729555922424006482349718367872728341488582101616235246588186593611095415808038042198502858722459071345965041451008 +0b1000101010101010000101010010101010001001001000101010001010010 >> 1035 = 0 +0b1000101010101010000101010010101010001001001000101010001010010 << -4 = negative shift count +0b1000101010101010000101010010101010001001001000101010001010010 >> -4 = negative shift count +str 32932583298439028439285392 +hex 0x1b3dbeeafa99ebe8787e90 +oct 0o15475575653724636575036077220 +bin 0b1101100111101101111101110101011111010100110011110101111101000011110000111111010010000 +32932583298439028439285392 + 42 = 32932583298439028439285434 +32932583298439028439285392 - 42 = 32932583298439028439285350 +32932583298439028439285392 * 42 = 1383168498534439194449986464 +32932583298439028439285392 | 42 = 32932583298439028439285434 +32932583298439028439285392 ^ 42 = 32932583298439028439285434 +32932583298439028439285392 & 42 = 0 +32932583298439028439285392 // 42 = 784109126153310200935366 +32932583298439028439285392 % 42 = 20 +32932583298439028439285392 + 7 = 32932583298439028439285399 +32932583298439028439285392 - 7 = 32932583298439028439285385 +32932583298439028439285392 * 7 = 230528083089073199074997744 +32932583298439028439285392 | 7 = 32932583298439028439285399 +32932583298439028439285392 ^ 7 = 32932583298439028439285399 +32932583298439028439285392 & 7 = 0 +32932583298439028439285392 // 7 = 4704654756919861205612198 +32932583298439028439285392 % 7 = 6 +32932583298439028439285392 + 0 = 32932583298439028439285392 +32932583298439028439285392 - 0 = 32932583298439028439285392 +32932583298439028439285392 * 0 = 0 +32932583298439028439285392 | 0 = 32932583298439028439285392 +32932583298439028439285392 ^ 0 = 32932583298439028439285392 +32932583298439028439285392 & 0 = 0 +32932583298439028439285392 // 0 = integer division or modulo by zero +32932583298439028439285392 % 0 = integer division or modulo by zero +32932583298439028439285392 + -2 = 32932583298439028439285390 +32932583298439028439285392 - -2 = 32932583298439028439285394 +32932583298439028439285392 * -2 = -65865166596878056878570784 +32932583298439028439285392 | -2 = -2 +32932583298439028439285392 ^ -2 = -32932583298439028439285394 +32932583298439028439285392 & -2 = 32932583298439028439285392 +32932583298439028439285392 // -2 = -16466291649219514219642696 +32932583298439028439285392 % -2 = 0 +32932583298439028439285392 + -53 = 32932583298439028439285339 +32932583298439028439285392 - -53 = 32932583298439028439285445 +32932583298439028439285392 * -53 = -1745426914817268507282125776 +32932583298439028439285392 | -53 = -37 +32932583298439028439285392 ^ -53 = -32932583298439028439285413 +32932583298439028439285392 & -53 = 32932583298439028439285376 +32932583298439028439285392 // -53 = -621369496196962800741234 +32932583298439028439285392 % -53 = -10 +32932583298439028439285392 + -25932 = 32932583298439028439259460 +32932583298439028439285392 - -25932 = 32932583298439028439311324 +32932583298439028439285392 * -25932 = -854007750095120885487548785344 +32932583298439028439285392 | -25932 = -332 +32932583298439028439285392 ^ -25932 = -32932583298439028439260124 +32932583298439028439285392 & -25932 = 32932583298439028439259792 +32932583298439028439285392 // -25932 = -1269959251058114624375 +32932583298439028439285392 % -25932 = -7108 +32932583298439028439285392 + -30250320993256832943892058390285932532 = -30250320993223900360593619361846647140 +32932583298439028439285392 - -30250320993256832943892058390285932532 = 30250320993289765527190497418725217924 +32932583298439028439285392 * -30250320993256832943892058390285932532 = -996221215914949498445947449761119526194805378587303760405172544 +32932583298439028439285392 | -30250320993256832943892058390285932532 = -30250320993253035900465085524945797476 +32932583298439028439285392 ^ -30250320993256832943892058390285932532 = -30250320993282171440336551688044947812 +32932583298439028439285392 & -30250320993256832943892058390285932532 = 29135539871466163099150336 +32932583298439028439285392 // -30250320993256832943892058390285932532 = -1 +32932583298439028439285392 % -30250320993256832943892058390285932532 = -30250320993223900360593619361846647140 +32932583298439028439285392 + 29394294398256832432748937248937198578921421 = 29394294398256832465681520547376227018206813 +32932583298439028439285392 - 29394294398256832432748937248937198578921421 = -29394294398256832399816353950498170139636029 +32932583298439028439285392 * 29394294398256832432748937248937198578921421 = 968030048769432851282694397002540906492053861479512032742127361182032 +32932583298439028439285392 | 29394294398256832432748937248937198578921421 = 29394294398256832434001151244850490827702237 +32932583298439028439285392 ^ 29394294398256832432748937248937198578921421 = 29394294398256832402320781942324754637197661 +32932583298439028439285392 & 29394294398256832432748937248937198578921421 = 31680369302525736190504576 +32932583298439028439285392 // 29394294398256832432748937248937198578921421 = 0 +32932583298439028439285392 % 29394294398256832432748937248937198578921421 = 32932583298439028439285392 +32932583298439028439285392 + 0x29589239862 = 32932583298441869713479410 +32932583298439028439285392 - 0x29589239862 = 32932583298436187165091374 +32932583298439028439285392 * 0x29589239862 = 93570499068202998486345582602681185056 +32932583298439028439285392 | 0x29589239862 = 32932583298441313378893554 +32932583298439028439285392 ^ 0x29589239862 = 32932583298440757044307698 +32932583298439028439285392 & 0x29589239862 = 556334585856 +32932583298439028439285392 // 0x29589239862 = 11590779716992 +32932583298439028439285392 % 0x29589239862 = 2401499931536 +32932583298439028439285392 + 0b1000101010101010000101010010101010001001001000101010001010010 = 32932584547416777902838498 +32932583298439028439285392 - 0b1000101010101010000101010010101010001001001000101010001010010 = 32932582049461278975732286 +32932583298439028439285392 * 0b1000101010101010000101010010101010001001001000101010001010010 = 41132063772105374230440788653395683882027552 +32932583298439028439285392 | 0b1000101010101010000101010010101010001001001000101010001010010 = 32932584524898087200390866 +32932583298439028439285392 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = 32932584502379396497943234 +32932583298439028439285392 & 0b1000101010101010000101010010101010001001001000101010001010010 = 22518690702447632 +32932583298439028439285392 // 0b1000101010101010000101010010101010001001001000101010001010010 = 26367630 +32932583298439028439285392 % 0b1000101010101010000101010010101010001001001000101010001010010 = 122351361654926612 +32932583298439028439285392 + 32932583298439028439285392 = 65865166596878056878570784 +32932583298439028439285392 - 32932583298439028439285392 = 0 +32932583298439028439285392 * 32932583298439028439285392 = 1084555042708625238098106961239666999129607624593664 +32932583298439028439285392 | 32932583298439028439285392 = 32932583298439028439285392 +32932583298439028439285392 ^ 32932583298439028439285392 = 0 +32932583298439028439285392 & 32932583298439028439285392 = 32932583298439028439285392 +32932583298439028439285392 // 32932583298439028439285392 = 1 +32932583298439028439285392 % 32932583298439028439285392 = 0 +32932583298439028439285392 + -5392583232948329853251521 = 27540000065490698586033871 +32932583298439028439285392 - -5392583232948329853251521 = 38325166531387358292536913 +32932583298439028439285392 * -5392583232948329853251521 = -177591696512836508422663710214843962092484877081232 +32932583298439028439285392 | -5392583232948329853251521 = -5139115686753003578065217 +32932583298439028439285392 ^ -5392583232948329853251521 = -37818231438996705742164305 +32932583298439028439285392 & -5392583232948329853251521 = 32679115752243702164099088 +32932583298439028439285392 // -5392583232948329853251521 = -7 +32932583298439028439285392 % -5392583232948329853251521 = -4815499332199280533475255 +32932583298439028439285392 << 0 = 32932583298439028439285392 +32932583298439028439285392 >> 0 = 32932583298439028439285392 +32932583298439028439285392 << 3 = 263460666387512227514283136 +32932583298439028439285392 >> 3 = 4116572912304878554910674 +32932583298439028439285392 << 23 = 276258531717952021478016953614336 +32932583298439028439285392 >> 23 = 3925869858078840784 +32932583298439028439285392 << 47 = 4634849058474932141973329682449695768576 +32932583298439028439285392 >> 47 = 234000078325 +32932583298439028439285392 << 68 = 9719982972678820891403652290208744380460695552 +32932583298439028439285392 >> 68 = 111579 +32932583298439028439285392 << 135 = 1434416306382566318695085125979448426590840865886402149195244896256 +32932583298439028439285392 >> 135 = 0 +32932583298439028439285392 << 1035 = 12124708640539689943817931059888789573235030495929601176577010792595578681810925900077258254421121567600162929936989784937971063214741712862171627435847536830160366346354469237076116244206524409699904173537264818368928309564168496559531209459105974428715456028743584974931482912393304842949455865438639358514301678410834286306902730080256 +32932583298439028439285392 >> 1035 = 0 +32932583298439028439285392 << -4 = negative shift count +32932583298439028439285392 >> -4 = negative shift count +str -5392583232948329853251521 +hex -0x475ec85d7c408d2a86fc1 +oct -0o2165731027276100432252067701 +bin -0b10001110101111011001000010111010111110001000000100011010010101010000110111111000001 +-5392583232948329853251521 + 42 = -5392583232948329853251479 +-5392583232948329853251521 - 42 = -5392583232948329853251563 +-5392583232948329853251521 * 42 = -226488495783829853836563882 +-5392583232948329853251521 | 42 = -5392583232948329853251521 +-5392583232948329853251521 ^ 42 = -5392583232948329853251563 +-5392583232948329853251521 & 42 = 42 +-5392583232948329853251521 // 42 = -128394838879722139363132 +-5392583232948329853251521 % 42 = 23 +-5392583232948329853251521 + 7 = -5392583232948329853251514 +-5392583232948329853251521 - 7 = -5392583232948329853251528 +-5392583232948329853251521 * 7 = -37748082630638308972760647 +-5392583232948329853251521 | 7 = -5392583232948329853251521 +-5392583232948329853251521 ^ 7 = -5392583232948329853251528 +-5392583232948329853251521 & 7 = 7 +-5392583232948329853251521 // 7 = -770369033278332836178789 +-5392583232948329853251521 % 7 = 2 +-5392583232948329853251521 + 0 = -5392583232948329853251521 +-5392583232948329853251521 - 0 = -5392583232948329853251521 +-5392583232948329853251521 * 0 = 0 +-5392583232948329853251521 | 0 = -5392583232948329853251521 +-5392583232948329853251521 ^ 0 = -5392583232948329853251521 +-5392583232948329853251521 & 0 = 0 +-5392583232948329853251521 // 0 = integer division or modulo by zero +-5392583232948329853251521 % 0 = integer division or modulo by zero +-5392583232948329853251521 + -2 = -5392583232948329853251523 +-5392583232948329853251521 - -2 = -5392583232948329853251519 +-5392583232948329853251521 * -2 = 10785166465896659706503042 +-5392583232948329853251521 | -2 = -1 +-5392583232948329853251521 ^ -2 = 5392583232948329853251521 +-5392583232948329853251521 & -2 = -5392583232948329853251522 +-5392583232948329853251521 // -2 = 2696291616474164926625760 +-5392583232948329853251521 % -2 = -1 +-5392583232948329853251521 + -53 = -5392583232948329853251574 +-5392583232948329853251521 - -53 = -5392583232948329853251468 +-5392583232948329853251521 * -53 = 285806911346261482222330613 +-5392583232948329853251521 | -53 = -1 +-5392583232948329853251521 ^ -53 = 5392583232948329853251572 +-5392583232948329853251521 & -53 = -5392583232948329853251573 +-5392583232948329853251521 // -53 = 101746853451855280250028 +-5392583232948329853251521 % -53 = -37 +-5392583232948329853251521 + -25932 = -5392583232948329853277453 +-5392583232948329853251521 - -25932 = -5392583232948329853225589 +-5392583232948329853251521 * -25932 = 139840468396816089754518442572 +-5392583232948329853251521 | -25932 = -25921 +-5392583232948329853251521 ^ -25932 = 5392583232948329853225611 +-5392583232948329853251521 & -25932 = -5392583232948329853251532 +-5392583232948329853251521 // -25932 = 207950919055542567223 +-5392583232948329853251521 % -25932 = -24685 +-5392583232948329853251521 + -30250320993256832943892058390285932532 = -30250320993262225527125006720139184053 +-5392583232948329853251521 - -30250320993256832943892058390285932532 = 30250320993251440360659110060432681011 +-5392583232948329853251521 * -30250320993256832943892058390285932532 = 163127373779541664871004168256892496317554452868422585832381172 +-5392583232948329853251521 | -30250320993256832943892058390285932532 = -5309341939605529581078465 +-5392583232948329853251521 ^ -30250320993256832943892058390285932532 = 30250320993251606843245795660977027123 +-5392583232948329853251521 & -30250320993256832943892058390285932532 = -30250320993256916185185401190558105588 +-5392583232948329853251521 // -30250320993256832943892058390285932532 = 0 +-5392583232948329853251521 % -30250320993256832943892058390285932532 = -5392583232948329853251521 +-5392583232948329853251521 + 29394294398256832432748937248937198578921421 = 29394294398256832427356354015988868725669900 +-5392583232948329853251521 - 29394294398256832432748937248937198578921421 = -29394294398256832438141520481885528432172942 +-5392583232948329853251521 * 29394294398256832432748937248937198578921421 = -158511179116386811499406594352977335675254166910582965199250007731341 +-5392583232948329853251521 | 29394294398256832432748937248937198578921421 = -5469532876153509380097 +-5392583232948329853251521 ^ 29394294398256832432748937248937198578921421 = -29394294398256832427367293081741175744430094 +-5392583232948329853251521 & 29394294398256832432748937248937198578921421 = 29394294398256832427361823548865022235049997 +-5392583232948329853251521 // 29394294398256832432748937248937198578921421 = -1 +-5392583232948329853251521 % 29394294398256832432748937248937198578921421 = 29394294398256832427356354015988868725669900 +-5392583232948329853251521 + 0x29589239862 = -5392583232945488579057503 +-5392583232948329853251521 - 0x29589239862 = -5392583232951171127445539 +-5392583232948329853251521 * 0x29589239862 = -15321807578870246645636423545907601378 +-5392583232948329853251521 | 0x29589239862 = -5392583232948327703668609 +-5392583232948329853251521 ^ 0x29589239862 = -5392583232951166828279715 +-5392583232948329853251521 & 0x29589239862 = 2839124611106 +-5392583232948329853251521 // 0x29589239862 = -1897945381091 +-5392583232948329853251521 % 0x29589239862 = 1187029262117 +-5392583232948329853251521 + 0b1000101010101010000101010010101010001001001000101010001010010 = -5392581983970580389698415 +-5392583232948329853251521 - 0b1000101010101010000101010010101010001001001000101010001010010 = -5392584481926079316804627 +-5392583232948329853251521 * 0b1000101010101010000101010010101010001001001000101010001010010 = -6735216470082696360420304870393495758774226 +-5392583232948329853251521 | 0b1000101010101010000101010010101010001001001000101010001010010 = -5392583136894992706448257 +-5392583232948329853251521 ^ 0b1000101010101010000101010010101010001001001000101010001010010 = -5392584289819405023198099 +-5392583232948329853251521 & 0b1000101010101010000101010010101010001001001000101010001010010 = 1152924412316749842 +-5392583232948329853251521 // 0b1000101010101010000101010010101010001001001000101010001010010 = -4317598 +-5392583232948329853251521 % 0b1000101010101010000101010010101010001001001000101010001010010 = 600180008110107867 +-5392583232948329853251521 + 32932583298439028439285392 = 27540000065490698586033871 +-5392583232948329853251521 - 32932583298439028439285392 = -38325166531387358292536913 +-5392583232948329853251521 * 32932583298439028439285392 = -177591696512836508422663710214843962092484877081232 +-5392583232948329853251521 | 32932583298439028439285392 = -5139115686753003578065217 +-5392583232948329853251521 ^ 32932583298439028439285392 = -37818231438996705742164305 +-5392583232948329853251521 & 32932583298439028439285392 = 32679115752243702164099088 +-5392583232948329853251521 // 32932583298439028439285392 = -1 +-5392583232948329853251521 % 32932583298439028439285392 = 27540000065490698586033871 +-5392583232948329853251521 + -5392583232948329853251521 = -10785166465896659706503042 +-5392583232948329853251521 - -5392583232948329853251521 = 0 +-5392583232948329853251521 * -5392583232948329853251521 = 29079953924275461154997675156759795354976088813441 +-5392583232948329853251521 | -5392583232948329853251521 = -5392583232948329853251521 +-5392583232948329853251521 ^ -5392583232948329853251521 = 0 +-5392583232948329853251521 & -5392583232948329853251521 = -5392583232948329853251521 +-5392583232948329853251521 // -5392583232948329853251521 = 1 +-5392583232948329853251521 % -5392583232948329853251521 = 0 +-5392583232948329853251521 << 0 = -5392583232948329853251521 +-5392583232948329853251521 >> 0 = -5392583232948329853251521 +-5392583232948329853251521 << 3 = -43140665863586638826012168 +-5392583232948329853251521 >> 3 = -674072904118541231656441 +-5392583232948329853251521 << 23 = -45236266848576223393624535072768 +-5392583232948329853251521 >> 23 = -642846016043225510 +-5392583232948329853251521 << 47 = -758938619952202592339091847815404453888 +-5392583232948329853251521 >> 47 = -38316608432 +-5392583232948329853251521 << 68 = -1591609644710001570929111146829771081280126976 +-5392583232948329853251521 >> 68 = -18271 +-5392583232948329853251521 << 135 = -234880126249705491822419500935644814953821287158782357540047945728 +-5392583232948329853251521 >> 135 = -1 +-5392583232948329853251521 << 1035 = -1985374178722784350102150586746809086554653634753340636396021314166473714699054474961091360488125223233623787790612984822982284840293680850219784715739301030242748921121251700395772204861493971915285990947980875741238103926675726273700342380845052846901507589427594541156848370454583260171827672507218389658305172362814495925175716937728 +-5392583232948329853251521 >> 1035 = -1 +-5392583232948329853251521 << -4 = negative shift count +-5392583232948329853251521 >> -4 = negative shift count