0

I was implementing a code to calculate a modulus of a number.

Ex. long n = 70464307456L; // input value int res = n % 256;

The result I got here was 0, which is expected.

The next input was 070464307467L (this input had leading 0) I was expecting to get the result as 11 for this input, but the result I got was 55.

But when removed the leading 0 from the input, the result was 11.

I did not understand this behavior when 0 is at the beginning.

Can someone please help me to understand?

Thanks in Advance.

Ashyboy
  • 163
  • 1
  • 8

1 Answers1

0

When you place a leading zero on the long literal in Java, you are telling the compiler that you are writting an octal litteral.

MBurnham
  • 381
  • 1
  • 9