Bcrypt Generator
Hash a password with bcrypt, or check one against an existing hash.
Convert between signed and unsigned, with the negation steps shown.
Decimal, or prefixed 0x, 0b or 0o.
The Two’s Complement Converter shows the invert-and-add-one steps rather than just the answer, and shows the same bit pattern read as signed and as unsigned — which is where the real bugs live, because nothing about the bits says which was meant.
Two's complement is how every modern processor stores a negative integer, and it is much less mysterious once you see the three steps: write the magnitude in binary, invert every bit, add one. This shows those steps for any value at any width.
It also shows the same bit pattern read both ways, which is where real bugs live. The byte 11111011 is 251 if you read it unsigned and −5 if you read it signed; nothing about the bits says which is intended. That is the whole of the C signed/unsigned comparison trap, the reason a file size can come back negative, and why an overflowed value wraps to the far end of the range instead of saturating. The converter flags a value that does not fit in the width you chose and shows what it wraps to.
Magnitude, inverted, plus one — laid out in binary, which is what makes the algorithm implementable rather than memorised.
11111011 is 251 unsigned and −5 signed. Seeing both is the whole of the signed/unsigned comparison trap.
A value too large for the width is reported, with what it wraps to — so 200 in a signed byte is shown becoming −56.
8, 16, 32 and 64 bits, with the range for each so the asymmetry (−128 to 127) is explicit.
Decimal, hex, binary or octal, with or without a prefix.
Positive or negative, in decimal, hex, binary or octal.
8, 16, 32 or 64 bits.
For a negative number, the magnitude, the inversion and the result.
The same bits as a signed value and as an unsigned one.
Because addition and subtraction work unchanged. The same adder circuit handles negatives with no special case, and there is only one representation of zero — a sign-and-magnitude scheme gives you both +0 and −0.
Because zero takes up a slot on the positive side. An 8-bit signed byte runs from −128 to 127: 128 values below zero, 128 from zero up.
The value wraps around. Add 1 to 127 in a signed byte and you get −128, because the bits carried into the sign position. This is why overflow checks exist, and why some languages make it a hard error.
Invert every bit and add one — the same operation in both directions. Applying it twice returns the original value, which is exactly what you would want from negation.
What people who use the Two's Complement Converter think of it. Reviews come from visitors and are posted as written.
No ratings yet
Yours would be the first.
0 reviews
Newest first
No reviews yet
Be the first to rate the Two's Complement Converter. It takes half a minute and no account.
Write the first reviewHash a password with bcrypt, or check one against an existing hash.
Build a valid package.json with scripts, exports and metadata.
Build a docker-compose.yml with databases, caches and health checks.
Turn a JSON object into a TOML document with proper tables and arrays of tables.
Generate a production Dockerfile with multi-stage builds and layer caching.
Make every editor agree on indentation, line endings and charset.
Pick an open source licence and get a LICENSE file with your details.
Explore a JSON document as a collapsible tree with paths you can copy.