Workshop Division // Tool

BITWISE PLAYGROUND

One number, every view of it at once: binary, hex, octal, decimal signed and unsigned, and the bytes in either order. Click a bit and the whole page moves.

4

On a desktop, click any bit of A or B to flip it. Bit 0 is on the right, as it is in every datasheet ever written, and bytes are shaded alternately so you can count them without counting. Thirty-two bits cannot each be a thumb-sized target on a phone, so there the rows are a readout and the boxes above — which take hex, binary, octal or decimal — are how you set a value.



    
    

    

value[hi:lo], the way Verilog writes it: the bits from lo up to and including hi, shifted down to the bottom. Reading a register field, unpacking a float's exponent, or pulling the opcode out of an instruction is all the same operation.

Shifts and rotates here follow the rules that are actually written down rather than whatever a particular CPU does with an out-of-range count: a shift of width or more gives zero (or all sign bits, for an arithmetic right shift), and a rotate is taken modulo the width. C leaves the first case undefined and x86 quietly masks the count to 5 or 6 bits, which is a classic source of code that works until it is recompiled.

Incoming Transmission — Slippy

"Two's complement is not a trick. It is just counting backwards from zero and letting it wrap."

← Back to Archive