Browsers & softwarePractical guides

Choose the input base first: why 010 can mean eight or ten

The characters 010 do not specify their own base. An octal source means decimal eight; a decimal source means ten. Check the field contract before choosing the input base rather than guessing from the leading zero.

Books, a calculator and study supplies against a yellow background
Illustrative photo: McCarthy Beckan · Unsplash License

Key Takeaways

Set an explicit input base from 2 to 36 and verify the decimal value. In KitNelo, 010 with bases 2, 8, 10 and 16 becomes decimal 2, 8, 10 and 16 respectively. Negative binary output uses a minus sign, not fixed-width two’s complement. Preserve padded identifiers as text when their zeros matter.

In this article

Ask the source instead of asking the converter to guess

The field definition, protocol or exercise determines the base. 010 can be a number or a three-character identifier. For an identifier, leading zeros are a representation requirement; restoring them after numeric conversion needs an additional width rule. Equal values do not establish identical source identifiers.

This differs from text encoding round-trip checks. Encoding characters and interpreting numeric digits are separate tasks. This guide concerns signed integers, not fractions, floating-point bit patterns or file bytes in arbitrary units.

Keep 010 fixed and change only the input base

Open the number base converter, enter 010 and set Input number base to 2, 8, 10 and 16 in turn. Inspect the decimal line after each run. These original fixtures were recalculated with the current processing function. The explicit base controls interpretation; a leading zero does not automatically select octal.

For example, octal 010 equals 0×8²+1×8+0=8, while decimal 010 equals ten. If the receiver needs binary, confirm the decimal value before taking the binary line. A correct-looking representation can still express the wrong value when the input base is wrong.

Four interpretations of one source string
InputInput baseDecimal outputBinary output
0102210
010881000
01010101010
010161610000

-1010 is not a specified-width two’s-complement field

For decimal input -10, KitNelo outputs binary -1010. MDN’s BigInt string documentation distinguishes this signed string from two’s complement. Do not place it directly into a field that requires a fixed 8-, 16- or 32-bit representation.

If a device contract requires two’s complement, first establish the bit width, signedness and overflow behavior. The current tool does not offer a width selector and two’s-complement encoder. Removing the sign or blindly padding with zeros does not implement that contract.

Test long integers and invalid digits as well

The converter uses BigInt integer arithmetic. For original base-10 input 9007199254740993, the decimal result remains 9007199254740993 and hexadecimal is 20000000000001. Re-enter that hexadecimal value with base 16 to verify the same decimal value. Avoid an intermediate floating-point or automatic spreadsheet conversion that loses precision before the converter sees it.

As a negative test, 102 is not valid base-2 input because digit 2 is outside the base. Correct the source or selected base rather than handing off the valid prefix 10. The current tool rejects this input. Retain the original and document the basis for selecting a radix before retrying.

Across tools, also check string versus number types; the formatting semantics guide covers that issue. Integer conversion preserves the value, not all original padding, letter case or field types.

Include the interpretation in the handoff

Record the original input, input base, checked decimal value, target representation and any fixed-width requirement. Verify those after downloading rather than checking only that a file exists. If the source does not specify a base, ask its owner. Stable converter output cannot supply a missing contract.

Further reading & sources

Put the guide into practice

Open the relevant tool, preview the result and check your exported file.