CS Fundamentals beginner 8 min

Convert a Feature Flag Between Binary, Hex, and Decimal

Translate one flag value across number bases and catch where a copied constant changed meaning.

Scenario

A feature flag arrived in a bug report as 0b101101, the code review discusses 0x2D, and the database column stores 45. Three people are arguing about whether these are the same flag or three different ones. Converting binary to hex or hex to decimal in your head is exactly how off-by-one-bit mistakes ship, so prove the equivalence before anyone edits the flag.

Broken input

0b101101
0x2D
45

Goal

Use Binary / Hex / Decimal Converter to confirm whether the binary, hexadecimal, and decimal versions represent the same exact integer. If they match, the bug is elsewhere; if they differ, you have found where a copied constant changed meaning.

Tool sequence

  1. Open Binary / Hex / Decimal Converter.
  2. Enter 101101 as binary — the converter treats the 0b prefix as notation, so drop it if the tool flags it as an invalid digit.
  3. Read the decimal and hexadecimal fields the converter fills in, then repeat with 2D as hex and 45 as decimal.
  4. If any of the three entries lands on a different decimal value, that entry is the corrupted one — check whether a digit was dropped or a prefix misread.
  5. If the flag feeds a signed field or a permission mask, continue in Two's Complement Calculator or Bitwise Operations Calculator.

Checkpoint output

binary   101101
decimal  45
hex      2D

All three inputs converge on the same integer, so the flag value is consistent across the bug report, the review, and the database.

Common mistakes

  • Dropping a prefix before you know which base the original value used — 101101 read as decimal is one hundred one thousand, not 45.
  • Treating a grouped binary display like 10 1101 as if the spaces are part of the value.
  • Assuming a plain number in a bug report is decimal when the surrounding code writes flags in hex.
  • Converting one value and eyeballing the other two instead of running all three through the same converter.

Related tools and lessons