number_base MCP tool: hex, binary and two's complement
· 6 min read
Get the devtoolbox.cc MCP serverOpen the Number Base tool
Converting 255 to hex is easy enough that a model gets it right. Converting 0x7FFFFFFFFFFFFFFF to decimal, or the 32-bit pattern 0xFFFFFFF6 to a signed integer, is a different matter. Those take long multiplications or a careful bit-level reading, and models do arithmetic by predicting digits, not by computing them. The result is usually close, and close is wrong in a register dump or a permission mask.
The devtoolbox.cc MCP server includes number_base, which does these conversions with big-integer arithmetic. There’s no 2^53 limit and no rounding. It runs the same code as the number base converter on this site. Install steps are on the MCP page.
What the tool does
- Reads an integer in any base from 2 to 36, of any length.
- Accepts a minus sign,
0b,0oand0xprefixes that match the base, and_or spaces as digit separators, so values copied from code or a debugger work as they are. - Returns the value in decimal, binary, octal and hexadecimal.
- With
bitsset to 8, 16, 32 or 64, it also shows the two’s complement bit pattern and both readings of it: signed and unsigned.
Invalid digits are reported with the offending character instead of being skipped.
Arguments
| Argument | Type | Meaning |
|---|---|---|
value |
string | The number, e.g. "255", "0xff", "-42", "1_000_000". |
from_base |
integer 2–36 | Base of value. Default 10. |
bits |
8, 16, 32 or 64 |
Show the two’s complement pattern for this width. |
Examples
These examples were run against the real tool. The largest signed 64-bit integer, from hex:
{ "value": "0x7FFF_FFFF_FFFF_FFFF", "from_base": 16 }
Decimal: 9223372036854775807
Binary: 111111111111111111111111111111111111111111111111111111111111111
Octal: 777777777777777777777
Hexadecimal: 7fffffffffffffff
The value is passed as a string on purpose. As a JSON number, 9223372036854775807 would already have been rounded by many parsers before reaching the tool.
A 32-bit pattern from a register dump, read as a signed integer. 0xFFFFFFF6 is -10, the kind of value that turns up as an error code:
{ "value": "FFFFFFF6", "from_base": 16, "bits": 32 }
Decimal: 4294967286
Binary: 11111111111111111111111111110110
Octal: 37777777766
Hexadecimal: fffffff6
32-bit pattern: 11111111111111111111111111110110 (0xfffffff6)
Signed: -10
Unsigned: 4294967286
The other direction: what does -1 look like in 16 bits?
{ "value": "-1", "bits": 16 }
Decimal: -1
Binary: -1
Octal: -1
Hexadecimal: -1
16-bit pattern: 1111111111111111 (0xffff)
Signed: -1
Unsigned: 65535
Unix permission bits are octal. 0o755 as binary shows the three rwx groups:
{ "value": "0o755", "from_base": 8 }
Decimal: 493
Binary: 111101101
Octal: 755
Hexadecimal: 1ed
Base 36 uses all digits and letters, and shows up in short IDs and URL shorteners:
{ "value": "devtoolbox", "from_base": 36 }
Decimal: 1362268883662449
Binary: 100110101101111100111110000111001100011011001110001
Octal: 46557476071433161
Hexadecimal: 4d6f9f0e63671
Values that don’t fit the chosen width, and digits that don’t exist in a base, are errors:
{ "value": "300", "bits": 8 }
Does not fit in 8 bits (signed −128…127, unsigned 0…255)
{ "value": "1012", "from_base": 2 }
Invalid digit "2" for base 2
Reading bit flags
Flags packed into an integer are easiest to read in binary. Bits are numbered from the right, starting at 0, so in 0b1011_0010 bits 1, 4, 5 and 7 are set:
{ "value": "0b1011_0010", "from_base": 2 }
Decimal: 178
Binary: 10110010
Octal: 262
Hexadecimal: b2
An agent can then match the set bits against the flag definitions in your code. File modes work the same way in octal: each octal digit is three bits, read, write and execute. In 755 the owner has all three, and group and others have read and execute.
What two’s complement means
Computers store negative integers in two’s complement: the bit pattern of -1 is all ones, -2 is all ones except the last bit, and so on. The same 8 bits 11111111 mean 255 when read as unsigned and -1 when read as signed. A debugger, a hex dump or a network packet only shows the bits. Whether 0xFFFFFFF6 is 4294967286 or -10 depends on the type the program uses, which is why the tool shows both readings when you give it a width.
Base 32 is not Base32
Bases up to 36 use the digits 0–9 and then the letters a–z, case-insensitive, and that’s what the tool reads. Some encodings with similar names use different alphabets. RFC 4648 Base32, used for TOTP secrets in authenticator apps, uses A–Z followed by 2–7, so A is zero, not ten. Crockford’s Base32 skips easily confused letters. Base58 in cryptocurrency addresses and Base62 in some short-link services also have their own alphabets. Those are byte encodings rather than positional number systems, and reading them as plain base 32 or base 36 gives a different number. When an ID looks like base 36, check where it came from first.
Things to ask your assistant
- “The crash log says
exit status 0xC0000005. What’s that in decimal, and as a signed 32-bit value?” - “Convert the feature flags
0b1011_0010to hex and list which bits are set.” - “What’s the largest value of a signed 16-bit integer in hex?”
- “This config sets
mode: 420. What’s that in octal?”
The last one is a classic: 420 in decimal is 0644 in octal, a common file mode written in the wrong base. A tool answers it exactly, and the agent can then explain the permission bits.
For exploring values by hand, the number base converter on this site updates all bases as you type and shows the bit pattern. Hex digests from the hash generator are themselves big numbers in base 16, which this tool reads without losing digits.
Why big integers need code
JavaScript numbers, and the JSON parsers built on them, are exact only up to 2^53. Above that, 0x7FFFFFFFFFFFFFFF becomes 9223372036854775808 in many tools, one more than the correct value. A model reproducing such conversions from memory inherits the same errors, plus its own. number_base uses arbitrary-precision integers throughout, so a 64-bit or 128-bit value comes out exactly, whether it’s a register, a counter or a hash read as a number.
Install
number_base runs inside the devtoolbox.cc MCP server on your computer and makes no network requests. Setup for Claude Desktop, Claude Code, Cursor and VS Code is on the MCP install page.