bit wise operator and octal help
Author: JAVANewbs Jul 29, 2004 10:23 AM
I tried to do this problem,
System.out.println(010|4);
and I thought it's six but it's actually 12.
Why is it outcome is 12?
I read the answer, it is because 010 is octal but how to tells if it is octal or hex or binary?
[344 byte] By [
JAVANewbs] at [2007-9-30 14:13:59]

If the number begins with 0, it is octal, if it starts with 0x, it is hexadecimal.
Lacek at 2007-7-5 1:24:18 >

Only when you write 2, 02, 0x2, '\u0002', 1+1, or something like that.
Sorry for the confusion:Let walk from the beginning...
I tried to do this problem,
System.out.println(010|4);
and I thought it's six but it's actually 12.
Why is it outcome is 12?
I read the answer, it is because 010 is octal but how to tells if it is octal or hex or binary?
Hex is represented by ox
Oct is represented by 0
and what about binary?
Ah, so that's the problem. You can't write constants in binary, only in hex, octal, and decimal.