Category · 1 tool · 1 guide
Math and programming calculators
Programmers regularly do arithmetic that ordinary calculators handle badly. Reading a hex color or memory address, checking which bits a permission mask sets, working out what a negative number looks like in two's complement, or computing a network mask all require switching between number bases and thinking in fixed-width integers.
Mistakes in this area are subtle. An unsigned 32-bit value read as signed becomes negative, a right shift on a negative number behaves differently in Java and JavaScript, and an overflow in C wraps around silently. A desktop calculator in decimal mode cannot show you any of that, and doing it on paper is slow.
The tools in this category behave like real CPU registers: you choose the word size and signedness, and every result wraps exactly as it would in code. All calculations run in your browser using exact big-integer arithmetic, so 64-bit values are never rounded.
Tools in this category
Common tasks
- Check bits in a flags fieldAND a value with a mask to see whether a permission or feature flag is set, and flip individual bits.
- Understand negative numbers in binaryLearn how two's complement works and why shifts and overflow behave the way they do.
- Convert a timestamp in hexTurn a hex value from a binary log or protocol into decimal, then into a readable date.
- Read a hash as raw bytesCompute a checksum and inspect its hexadecimal digits byte by byte.
- Inspect the bits of an encoded valueSee how Base64 groups three bytes into four 6-bit characters.
Key concepts
- Number base
- Hexadecimal (base 16) writes each 4 bits as one digit, so a byte is exactly two hex digits. Binary shows individual bits, and octal is mostly seen in Unix file permissions like 0755.
- Word size
- Fixed-width integers hold 8, 16, 32 or 64 bits. Results that do not fit wrap around, so 255 + 1 in an unsigned 8-bit value is 0.
- Two's complement
- The way almost all CPUs store negative integers: invert the bits and add one. The top bit acts as the sign, so the 8-bit pattern 11111111 means -1 when signed and 255 when unsigned.
- Bitwise operators
- AND keeps bits set in both values, OR combines them, XOR keeps bits that differ and NOT flips all bits. They are used for flags, masks, hashing and low-level protocols.
- Arithmetic vs logical shift
- A logical right shift fills with zeros. An arithmetic right shift copies the sign bit, so negative numbers stay negative. JavaScript uses >>> and >> for the two.
Best practices
- Always state the word size and signedness when sharing a binary or hex value; the same bits mean different numbers.
- Use named constants for bit masks, such as FLAG_ADMIN = 1 << 3, instead of magic numbers.
- Remember that JavaScript bitwise operators work on 32-bit signed integers; use BigInt for 64-bit values.
- Check for overflow explicitly in languages that wrap silently, or use checked arithmetic helpers.
- Group long binary and hex literals with underscores, like 0xFFFF_FFFF, where your language allows it.