Try CircuitLens

Calculators

Number bases & bits calculator

One value shown in binary, decimal, hex and octal at once, with every bit clickable. Reading 0x2A is arithmetic; seeing 00101010 with bits 5, 3 and 1 lit is not — and that is what a datasheet's register table is really asking you to do. The mistake this exists to stop: the same bits are one number unsigned and a different one signed, so a sensor reporting −21 arrives as 65515 the moment you store it in an unsigned 16-bit variable. Type in any field — 0x2A, 0b101010, 0o52 or 42 all work anywhere.

Signed or unsigned — same bits, two answers

signed=unsigned−2N once the top bit is set; identical below that. Nothing in the register says which one is meant — only the type in your code does.

Bitwise operation

A is the value above. Setting, clearing and testing a flag are these four lines and nothing else: REG |= MASK, REG &= ~MASK, REG ^= MASK, if (REG & MASK).

ASCII

Half of serial debugging is deciding whether the byte you are staring at is a number or a letter. 0x41 is 65 is 'A'; there is no difference in the wire, only in how you print it.

Printable characters (32–126)

␣ is the space, code 32. Everything below 32 is a control code, and 127 is DEL — those are in the table under this one.

Control codes worth knowing

Related

More calculators