Binary adresse for localhost

Peter Hansen peter at engcorp.com
Thu Jun 19 08:46:41 EDT 2003


Benoit BESSE wrote:
> 
> for "224.4.0.1" the binary adresse is 0xe0040001L.

Actually, that's a hexadecimal value, not a binary one.
The difference is that binary refers to base 2, while
hexadecimal (hex==6, dec==10) refers to base 16.  Each
pair of digits, in this form, represents 8 binary bits,
for a total of 32 (aka a "long word").

> What is the corresponding convertion for 127.0.0.1.

Python's hex() method is helpful here:  hex(127) == 7f
the same way that hex(224) is e0.

-Peter




More information about the Python-list mailing list