Binary Word Size Converter
Convert binary values between 8-bit, 16-bit, 32-bit and 64-bit word sizes. Apply unsigned zero extension, signed two’s-complement sign extension or truncation and see whether narrowing loses information.
What Is a Binary Word Size?
A binary word size is the fixed number of bits used to represent a value. Common machine word sizes include 8, 16, 32 and 64 bits.
When a value moves between different word sizes, the representation may need to be extended or truncated depending on whether the new word is wider or narrower.
Zero Extension
Zero extension is normally used when widening an unsigned binary value. Zeros are added to the most-significant side until the target width is reached.
11110010
16-bit zero extension:
0000000011110010
The unsigned numeric value remains unchanged.
Sign Extension
Sign extension is used when widening a signed two’s-complement number. Copies of the source sign bit are added to the left.
11110010
Sign bit:
1
16-bit sign extension:
1111111111110010
This preserves the signed two’s-complement value.
Binary Truncation
When converting to a smaller word size, the most-significant bits must be discarded and the least-significant target-width bits are retained.
0001001010110010
Convert to 8-bit:
10110010
Truncation can change the numeric value, so the calculator reports whether important high-order information was lost.
Unsigned vs Signed Word Conversion
| Conversion | Unsigned | Signed Two’s Complement |
|---|---|---|
| Widening | Zero extension | Sign extension |
| Added high bits | Always 0 | Copies of sign bit |
| Narrowing | Truncate MSBs | Truncate MSBs |
| Preservation test | Discarded bits should be 0 | Discarded bits must form a valid sign extension |
Common Binary Word Sizes
| Word | Bits | Hex Digits | Unsigned Maximum |
|---|---|---|---|
| Byte | 8 | 2 | 255 |
| 16-bit Word | 16 | 4 | 65,535 |
| 32-bit Word | 32 | 8 | 4,294,967,295 |
| 64-bit Word | 64 | 16 | 18,446,744,073,709,551,615 |
Signed 8-Bit to 16-Bit Example
Consider the 8-bit two’s-complement value:
Signed decimal:
-14
16-bit result:
1111111111110010
Signed decimal remains:
-14
Unsigned 8-Bit to 16-Bit Example
11110010
Unsigned decimal:
242
16-bit result:
0000000011110010
Unsigned decimal:
242
The same eight source bits therefore produce different 16-bit representations depending on whether they are treated as signed or unsigned.
When Does Narrowing Lose Information?
Unsigned Value
An unsigned narrowing conversion is lossless only when every discarded high-order bit is zero.
Signed Value
A signed narrowing is lossless only when the original value can still be represented within the smaller signed range.
0000000011110010
to 8-bit:
11110010
Unsigned source = 242
Unsigned result = 242
No unsigned information loss
Where Word Size Conversion Is Used
Programming
Integer conversions between byte, short, int and larger machine types can involve extension or truncation.
Computer Architecture
Processors frequently move values between registers or operations that use different widths.
Embedded Systems
Hardware registers and communication values commonly use fixed 8-bit, 16-bit or 32-bit sizes.
Binary Data Formats
Parsing a binary format may require interpreting stored fields at an exact fixed width.
Important Word Size Conversion Notes
Unsigned widening uses zero extension.
Signed two’s-complement widening uses sign extension.
Narrowing keeps the least-significant target-width bits and removes higher-order bits.
A narrowing operation can alter the original numeric value.
The signed decimal result is interpreted independently using the selected word width.
Leading zeros and leading sign bits are important because they define the complete machine word representation.