Table 1:Unsigned representation
Binary | Integer |
|---|---|
| 0 |
| 1 |
| 2 |
| 3 |
… | … |
| 255 |
Table 2:Sign-magnitude representation
Binary | Integer |
|---|---|
| 0 |
| 1 |
| 2 |
| 3 |
| 127 |
| -0 |
| -1 |
| -2 |
… | … |
| -125 |
| -126 |
| -127 |
Table 3:Ones’ complement representation
Binary | Integer |
|---|---|
| 0 |
| 1 |
| 2 |
| 3 |
| 127 |
| -127 |
| -126 |
| -125 |
… | … |
| -2 |
| -1 |
| -0 |
Table 4:Two’s complement representation
Binary | Integer |
|---|---|
| 0 |
| 1 |
| 2 |
| 3 |
| 127 |
| -128 |
| -127 |
| -126 |
… | … |
| -3 |
| -2 |
| -1 |
let c = -16i8;
println!("{c:b}");
let c = -16i16;
println!("{c:b}");
let c = 16i8;
println!("{c:b}");
let c = 16u8;
println!("{c:b}");11110000
1111111111110000
10000
10000