How to check if an integer is in octal form?

Hello, there, out of the consideration of security I want to convert any integer x to another integer y = f(x) ,

1) the sign of y must be the same as that of x, (i.e. if x < 0, then y < 0; and vice versa).

2)if I get an integer, I should know if it is the original number or it is the result of a conversion.

My solution to 2) is: all the results of the conversion will be displayed in octal or in hexadecimal, and the original integers in decimal.

My problems are:

1)With Integer.toBinaryString(int x) I get a String of an unsigned 2-complement of x, how can I get it as an integer, not as a String?For instance, I want to get -1100(Binary) from -12(Decimal), not 11...11110100.

2)How can I distinguish an octal integer from a decimal? Is there a method like "isOctal(int i)" in Java with which I can check if an integer is in octal form?

System.out.println(013) will print 11 automatically on the screen, how did Java do that? (Yes, I know an octal integer begins always with a 0, and I can write a few lines of codes to do that, but I think there must be a method in Java to do that, I just can't find it although I have been looking for it:(Thanks a lot.

[1224 byte] By [javavoid] at [2007-9-27 14:42:50]
# 1
Integers, of themselves, are not octal or decimal: they're always binary. You just compare integers to integers. If you want to "see" an integer in Octal (or Hex or any thing else), you need to output a formatted string (see NumberFormat).
crackers at 2007-7-5 22:42:41 > top of Java-index,Archived Forums,New To Java Technology Archive...