In Java an integer beginning with 0 is treated as an octal (base 8).
If we write numbers with more than one significant digit we might be confused by the result.
Octal numbers can only use digits 0-7, like decimal can use 0-9 and binary can use 0-1.
010 = = 8
024 = = 20
So we should always take care to never begin an integer with 0.
You can refer to 'http://docs.oracle.com/javase/specs/jls/se8/jls8.pdf' page no. 28. It says "An octal numeral consists of an ASCII digit 0 followed by one or more of the ASCII digits 0 through 7 interspersed with underscores, and can represent a positive, zero, or negative integer"
No comments:
Post a Comment
Thanks for your comments/Suggestions.