Settings

The number

Signed: Bytes: Width: bits

Bitwise and arithmetic

The operation applies the operand to the current number, at the chosen width. NOT ignores the operand.

How it works

Width and sign are the whole point

The same bits are a different number depending on how wide the register is and whether it is signed: 0xFF is 255 or −1, a right shift fills with zeros or the sign bit, an add wraps at the width. RADIX shows all of it at once and computes exactly in two's-complement to 64 bits, so you read the answer instead of deriving it.

Questions people ask about RADIX

What is two’s complement?

The way almost every processor stores signed integers. In an n-bit number the top bit counts as minus 2n−1 instead of plus, so the same bits can be read two ways. At 8 bits, 0xFF is 255 unsigned and −1 signed, and 0x80 is 128 or −128.

To negate a number, invert every bit and add one. That rule is why addition and subtraction work the same for signed and unsigned values, and only comparison, division and right shifts have to know which they are.

How do I see a negative number in hex or binary?

Type it with a minus sign in the decimal box. At 32 bits, -1 becomes FFFFFFFF, and the decimal box then shows it as the unsigned 4294967295 while the Signed line shows −1. Change the width and the same number is shown as it would sit in a register of that size.

What is the difference between a logical and an arithmetic right shift?

Both move every bit to the right. A logical shift fills the top with zeros; an arithmetic shift copies the sign bit, so a negative number stays negative and the shift divides it by two, rounding down. At 8 bits, 0x80 shifted right by one is 0x40 logically and 0xC0 arithmetically.

In C, which one a signed right shift gives has historically been left to the compiler; Java and JavaScript spell it out with >>> for logical and >> for arithmetic.

What happens when a result is too big for the width?

It wraps, as a fixed-width register does. At 8 bits, 255 + 1 is 0, and every operation keeps only the bits that fit the chosen width.

Changing the width to a narrower one cuts the current number down to its low bits. Widening again does not bring the lost bits back.

Does division treat numbers as signed?

No. ÷ and mod work on the unsigned value at the chosen width and round towards zero, so at 8 bits −8 ÷ 2 is read as 248 ÷ 2 and gives 124, not −4. Dividing by zero is refused with a message rather than giving a result.

What is the difference between a shift and a rotate?

A shift drops the bits that fall off one end and fills the other with zeros (or the sign bit, for an arithmetic right shift). A rotate puts the bits that fall off one end back in at the other, so nothing is lost. ROL and ROR rotate within the chosen width, which matters: rotating a value at 8 bits and at 32 bits gives different answers.

What can I type into the boxes?

Each box reads its own base, and a prefix overrides it: 0x for hex, 0o for octal and 0b for binary. Underscores, spaces and commas are ignored, so 1111_0000 and 1,000,000 both work. The operand for an operation is read as decimal unless it has one of those prefixes.

The Bytes line lists the bytes most significant first, the order you read the hex in. Memory on x86 and ARM holds them the other way round.

Doing this often? OBSCURA Umbra edits a folder of code where it is and runs JavaScript, TypeScript and Python in a sandbox. Everything is US$5 a month or US$48 a year.