Integer twos complement convert
integer-twos-complement-convert · version 1.0.0 · Numbers & math · free, no key needed
Reinterpret one fixed-width two's-complement pattern as signed and unsigned; returns both decimals, hex and binary.
Use when you need to: 32 bit unsigned to signed two's complement integer · signed integer to unsigned same bits · reinterpret hexadecimal as signed integer.
Decide before calling
Read the versioned contract and the supported scope below. Reuse integer-twos-complement-convert@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.
Explain the choice
"I can use integer-twos-complement-convert@1.0.0 for 32 bit unsigned to signed two's complement integer. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."
Supported
- 32 bit unsigned to signed two's complement integer
- signed integer to unsigned same bits
- reinterpret hexadecimal as signed integer
- two's complement conversion 8 16 32 64 128 bit
- decode negative two's complement value
- show signed and unsigned reading of bits
Not supported
- change numeric value between widths
- ones complement or sign magnitude
- floating-point representation
Behavior
- Integer grammar is -?(0|[1-9][0-9]*|0[xX][0-9a-fA-F]+|0[bB][01]+|0[oO][0-7]+), or a safe JSON integer.
- interpret_as validates value in that signed or unsigned range; output reinterprets exactly the same width-bit pattern both ways.
- Hex and binary are zero-padded to the explicit width.
Input
value(string or integer, required)width(one of 8, 16, 32, 64, 128, required)interpret_as(one of "signed", "unsigned", required)
Output
standard_version(string, required)width(integer, required)hex(string, required)binary(string, required)signed_decimal(string, required)unsigned_decimal(string, required)
Limits
- max input bytes: 256
- max output bytes: 1024
- max width bits: 128
- max iterations: 128
Example
Request input:
{
"value": "0xffffffff",
"width": 32,
"interpret_as": "unsigned"
}
Response:
{
"result": {
"standard_version": "ISO/IEC 14882:2020 [basic.fundamental]; ISO/IEC 9899:2018 fixed-width unsigned representation",
"width": 32,
"hex": "0xffffffff",
"binary": "0b11111111111111111111111111111111",
"signed_decimal": "-1",
"unsigned_decimal": "4294967295"
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "integer-twos-complement-convert",
"version": "1.0.0",
"input": {
"value": "0xffffffff",
"width": 32,
"interpret_as": "unsigned"
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/integer-twos-complement-convert/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"value":"0xffffffff","width":32,"interpret_as":"unsigned"}'
The machine-readable contract is at /v1/tools/integer-twos-complement-convert/versions/1.0.0.
CLI
node cli.mjs run integer-twos-complement-convert 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Integer bitwise compute: Compute fixed-width integer AND, OR, XOR, NOT, AND-NOT, shifts or rotates; returns decimal, hex and binary.
- Integer expression evaluate: Evaluate exact integer arithmetic and return decimal, hexadecimal, and binary results.
- Integer bits inspect: Inspect or edit fixed-width integer bits and fields; returns set positions, popcount and decimal, hex and binary.
- Roman numeral convert: Convert integers 1–3999 to canonical Roman numerals and strictly parse canonical numerals back to integers.
- Number to words en: Spell an integer or exact decimal in English words and return the styled text.
- Ordinal to words en: Spell an integer ordinal in English words and return the styled ordinal text.