2026-10-18 · 6 min read · Rahul Chitturi
- numbers
- hex
- debugging
Flashman's number-bases tool has one input, and that input is decimal. It trims the text, calls parseInt with radix 10, and prints the value in binary, octal, and lowercase hex with toString. It does not accept a hex or binary field, and it does not read a 0x or 0b prefix as a base marker.
parseInt stops at the first character that is not a decimal digit, after an optional sign. The rest of the string is discarded. If the parse is not a finite number, the tool prints Invalid decimal. Empty input, NaN, and Infinity land there. A string that yields a number, even a number that stopped early, does not.
See the character that ended the parse
42.9 prints the bases of 42. The dot ends the parse, so the .9 is not rounded and is not a fraction. 10.0 prints the bases of 10. 1e2 prints the bases of 1, because e is not a decimal digit. 1_000 prints the bases of 1. 42abc prints the bases of 42. A numeric separator or a unit suffix does not make the tool reject the line.
0x10 prints the bases of 0. The x stops the parse immediately. 0b1010 also prints 0. 08 prints 8: radix 10 does not treat a leading zero as octal. Spaces around 42 are ignored by the trim, and +42 is 42. If you meant the hex value 10, type 16 in the decimal box. The prefix belongs in your notes, not in the field.
- Type digits, not 0x or 0b.
- Remove fractional parts before you paste.
- Remove underscores and unit suffixes.
- Treat a suspiciously small result as an early stop.
Stay inside the exact integer range
JavaScript numbers are exact for integers through 9007199254740991. That value is safe, and its hex print is 1fffffffffffff. The next integer, 9007199254740993, is parsed as 9007199254740992, which is not a safe integer, and the hex print is 20000000000000. The tool has no separate warning for that rounding. The binary line is the rounded number, not the digits you typed.
A minus sign is kept as a prefix. -42 prints -101010 in binary, -52 in octal, and -2a in hex. That is not a two's-complement bit pattern. A bitmask has to be non-negative before these columns mean bit positions. 255 prints ff, with no 0x and no leading zero. Two hex digits for a byte are your job when the value is below 16: 10 prints a, not 0a.
Diff the integer you typed with the integer it used
Write the original text next to the decimal value implied by the hex column. If they differ, the parser stopped or rounded. Do not feed the hex column back into the same box: the box would read those letters as the end of a decimal parse.
Use the number-bases tool on a plain decimal integer, the JSON formatter when that integer is a JSON number that may already have been rounded, and diff when a datasheet, a log, and the tool disagree. The note should contain the digits you typed and the hex line you are about to copy.