murtaza.webdev murtaza.webdev - 2 months ago 17
Java Question

Whats difference between this two: BigInteger.valueOf(10000) and BigInteger.valueOf(0010000)?

I was working with one problem and came across this. What happen is:

when we use this:

it gives value of


when we use this
it gives value of

Whats the difference between the two?


00100000 is an octal literal. This has nothing to do with BigInteger - it's just Java integer literals (JLS 3.10.1):

System.out.println(10000);   // 10000
System.out.println(0010000); // 4096

From the JLS:

A decimal numeral is either the single ASCII digit 0, representing the integer zero, or consists of an ASCII digit from 1 to 9 optionally followed by one or more ASCII digits from 0 to 9 interspersed with underscores, representing a positive integer.


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.