How this calculation works
The leading bit has negative weight. For an eight-bit value, its weight is −128.
Encode n mod 2ʷ in w bitsA worked example
At eight bits, −18 is represented as 238, or 11101110.
Good to know
The signed input must fit the selected width.
Reference: NIST DLMF, Functions of Number Theory (opens in a new tab) ↗
Read the result
Represent a signed integer in a chosen two’s complement width.
The primary result is labeled “Bit representation”. Keep the input definitions in view when comparing this result with another method.
Try a related calculation
The signed input must fit the selected width.
For a related exercise, try the greatest common divisor.
A few questions, answered
How can I check the default inputs by hand?
At eight bits, −18 is represented as 238, or 11101110.
Which rule does this calculator apply?
Encode n mod 2ʷ in w bits