Why are Octal numeric literals not allowed in strict mode (and what is the workaround?)

Octal literals are not allowed because disallowing them discourages programmers from using leading zeros as padding in a script. For example, look at the following snippet: var eight = 0008, nine = 00009, ten = 000010, eleven = 011; console.log(eight, nine, ten, eleven); Seems harmless enough, right? We programmers with OCD just want to align … Read more

Is 00 an integer or octal in Java?

All are integers, but… 1 is decimal 0 is decimal 01 is octal 00 is octal From Java Language Specification (emphasis mine): Note that octal numerals always consist of two or more digits; 0 is always considered to be a decimal numeral – not that it matters much in practice, for the numerals 0, 00, … Read more

Parse error: Invalid numeric literal

This comes from the changes made to how integers, specifically octals, are handled in PHP7 (as oppsoed to PHP5). From the documentation (from PHP7 migration) Invalid octal literals Previously, octal literals that contained invalid numbers were silently truncated (0128 was taken as 012). Now, an invalid octal literal will cause a parse error. From the … Read more

Strange behaviour with numbers that have a leading zero [duplicate]

If you simply write 08 and 09 (without quotes) or any other numeric with a leading 0, PHP believes you’re writing an octal value, and 08 and 09 are invalid octal numbers. http://www.php.net/manual/en/language.types.integer.php Syntax Integers can be specified in decimal (base 10), hexadecimal (base 16), octal (base 8) or binary (base 2) notation, optionally preceded … Read more