gvwilson / sdxpy

Software Design by Example: a tool-based introduction with Python
https://third-bit.com/sdxpy/
Other
373 stars 55 forks source link

/binary - Section 17.1: Integers (2023-08-17) #219

Closed hectorcorrea closed 1 year ago

hectorcorrea commented 1 year ago

The last paragraph says:

Each hexadecimal digit corresponds to four bits (Table 17.2), which makes it 
easy to translate bits to digits and vice versa: for example, 0xF7 is 0b11110111. 
One advantage of this representation is that two hexadecimal digits is exactly one byte.

The part about "four bits" and "exactly one byte" seem disconnected. I would put them next to each other like shown below.

One advantage of this representation is that each hexadecimal digit corresponds to four bits (Table 17.2) 
and therefore two hexadecimal digits is exactly one byte. This representation also makes easy to translate 
bits to digits and vice versa: for example, 0b11110111 is 0xF7 (0b1111 is 0xF and 0x0111 is 0x7). 

I also switched the bits to digits example to match the sentence (bits first, hex digits last)