Wrong math with Python?

Because of octal arithmetic, 013 is actually the integer 11.

>>> 013
11

With a leading zero, 013 is interpreted as a base-8 number and 1*81 + 3*80 = 11.

Note: this behaviour was changed in python 3. Here is a particularly appropriate quote from PEP 3127

The default octal representation of integers is silently confusing to
people unfamiliar with C-like languages. It is extremely easy to
inadvertently create an integer object with the wrong value, because
‘013’ means ‘decimal 11’, not ‘decimal 13’, to the Python language
itself, which is not the meaning that most humans would assign to this
literal.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)