Friday 30 June 2017

Binary, Octal and Hexadecimal Integer in Python

Cited from the book "Data Structure and Python"

In some contexts, it is convenient to express an integral value using binary, octal, or hexadecimal. That can be done by using a prefix of the number 0 and then a character to describe the base. Example of such literals are respectively 0b1011, 0o52, and 0x7f.

No comments:

Post a Comment