UTILITIES NEWBIE

Integer and bitwise expressions

Evaluate integer arithmetic and bitwise operations with explicit signed 64-bit bounds. No variables, functions or JavaScript execution.

Input

0 UTF-16 code units

Inputs start empty. Load example fills them only when you choose it. Reset clears current inputs and results.

Output

Decimal output is signed64-bit. Hexadecimal/binary show the same value as unsigned64-bit two’s-complement bits. Overflow is rejected, not wrapped.4,096 expression characters;1,000 tokens;40 parser levels. Division truncates toward zero; right shift is arithmetic; shift count0–63. No variables, functions or executable code.

This tool processes inputs in your browser. See the Privacy Policy for details about hosting and performance measurement.

Intersect then set one bit. Full explanation follows.
1101 AND 1011 = 1001. Text explanation

Low four-bit diagram of the checked mask expression: thirteen AND eleven gives nine; OR two gives eleven. Full output pads hexadecimal to sixteen digits and binary to sixty-four bits; no packet byte order is implied.

Read an integer mask before copying its representation

Choose the integer operation you actually mean

The bitwise calculator evaluates a small integer-expression language and reports one value in decimal, hexadecimal and binary. Decimal is signed; hexadecimal and binary are the same value displayed as unsigned sixty-four-bit two’s-complement bits. This helps when comparing a feature mask, a protocol field or an integer example. It does not decode a complete packet or discover what a particular bit means in an external specification. Enter the expression as text, keep the original mask labels separately, and check the consumer’s width and signedness before interpreting the representation.

Supported literals include ordinary decimal integers, hexadecimal with a zero-x prefix and binary with a zero-b prefix. The allowed operators cover addition, subtraction, multiplication, integer division, remainder, AND, OR, XOR, complement and signed shifts, together with parentheses and unary signs. There are no variables, function calls or executable statements. A pasted JavaScript expression is therefore not automatically valid input. Write the actual integer arithmetic you want to inspect instead of pasting application code and expecting the page to execute it or look up named constants.

A good starting task is checking which low bits survive a mask. Keep the mask and the original value next to the expression in your own notes. A correct numerical result does not establish whether a flag is enabled in a real application, whether a packet is trusted or whether an account has permission to perform an action. Those meanings come from the consuming system. This page provides reproducible arithmetic under an explicit bounded model, allowing a reviewer to inspect the calculation without silently importing another programming language’s coercion rules.

Follow an AND result into an OR result

Checked synthetic input

source: (0b1101 & 0b1011) | 0x2

Recorded processor observation

Decimal: 11
Hex (64-bit two’s complement): 000000000000000b
Binary (64-bit): 0000000000000000000000000000000000000000000000000000000000001011

The checked expression combines binary thirteen with binary eleven using AND, then combines that result with hexadecimal two using OR. Thirteen has low bits one-one-zero-one; eleven has one-zero-one-one. AND retains only positions that are one in both operands, giving one-zero-zero-one, which is decimal nine. OR with two then sets the next low bit and produces one-zero-one-one, decimal eleven. The parentheses make the intended grouping easy to review rather than requiring the reader to remember the operator precedence table.

The observed output reports decimal eleven, a sixteen-digit hexadecimal representation ending in zero-b and a sixty-four-digit binary representation ending in one-zero-one-one. Leading zero bits are part of the fixed-width display, not additional significant decimal digits. The diagram shows the short low-bit reasoning while the checked output block preserves the full representation. When transferring the result, do not confuse the hexadecimal letter b with an identifier or change the fixed-width hexadecimal output into a decimal string without explicitly converting its base.

A second checked boundary example is complement of zero. Its signed decimal result is minus one, while the hexadecimal line is sixteen f characters and the binary line contains sixty-four ones. Those lines are different representations of one bounded value, not contradictory answers. Comparing only the decimal line with an unsigned register display can make an ordinary signedness difference appear to be a calculation error. State the representation alongside the value when documenting the example, especially when a consumer expects an unsigned field or a different register width.

Understand precedence, division and rejected overflow

The implementation groups unary operations first, then multiplication, division and remainder, then addition and subtraction, shifts, AND, XOR and OR. Operators within one binary precedence level associate to the left. Parentheses are still useful documentation when mixing arithmetic and bit operations. For example, shifting a sum is different from adding a shifted operand. Use a deliberately small specimen and compare its intermediate values before applying the same pattern to an unfamiliar expression. The page does not supply an expression debugger or named-variable environment.

Division truncates toward zero. The checked expression minus seven divided by two therefore produces minus three, rather than a fractional result or the mathematical floor of minus four. Right shift is signed: minus eight shifted right by two yields minus two. Shift counts must be between zero and sixty-three. There is no unsigned triple-right-shift operator in this language. Treating this tool as a floating-point calculator or assuming a different language’s shift-count masking would change the operation being tested and can produce misleading comparisons.

The signed result range runs from minus two to the sixty-third power through two to the sixty-third power minus one. Overflow is rejected rather than wrapped into the opposite sign. Division by zero and unsupported syntax also produce errors. The processor limits expressions to four thousand ninety-six characters, one thousand tokens and forty nesting levels. These are bounds on this parser, not a promise to accept every expression that another integer library can evaluate. Keep the original failing expression instead of removing pieces until a different calculation happens to pass.

Use the three representations as a review record

For a teaching example, begin with small masks whose low bits can be written out manually. Compare the AND and OR steps with the full output, then try a negative value to expose signedness. This gives a concrete explanation of what changed instead of merely displaying a large binary string. The visible diagram and text equivalent convey the same reasoning without requiring a color cue. It is reasonable to reuse the method for a synthetic fixture, but the fixture’s bit labels must come from the actual exercise or protocol you are explaining.

For application work, retain the expression, the chosen interpretation and the complete generated text. Copy and Download transfer that text; they do not update a device, patch a binary file or authorize a configuration change. If a downstream system requires little-endian bytes, a particular prefix or a narrower field, define and test that additional conversion separately. This output is a textual numerical representation, not an automatically serialized memory layout. A leading zero, byte order and character encoding are separate concerns from the integer value.

When a calculation fails, distinguish syntax, range, zero division and shift-count errors before changing the input. Check parentheses and literal prefixes first, then inspect the intended arithmetic with smaller values. A successful replacement is evidence for that replacement only. The useful result is a reviewed integer with its width, base and signedness attached, together with any consumer-specific checks still required. Keep private production values out of examples when synthetic masks answer the question, and preserve the original source of truth outside the tool.

Supporting reference: Integer context; this parser has its own signed64 bounds.

Find a tool

Type a tool name, such as JSON or percentage.

Quick links

Browse by category

All tools