hi nikita,
lets take a simple number -15. since u already know how to convert this to binary i will not harp on this issue.
the binary for -15 is 1111 1111 1111 1111 1111 1111 1111 0001
1111 gives us 2^3+2^2+2^1+2^0 = 15
now 15 is represented in hex as f
and 0001 gives us 1
now 1 is represented in hex as 1
so -15 in hex is 0xf1
in octal however it takes 3 bits thus -15 in this case is
11 111 111 111 111 111 111 111 111 110 001
ie
3 7 7 7 7 7 7 7 7 6 1
or 37777777761
here is a program to check this up
class demo
{
public static void main(
String[] args)
{int i=-15;
System.out.println(Integer.toHexString(i));
System.out.println(Integer.toOctalString(-15));
}
}
regds.
Rahul.
[This message has been edited by rahul_mkar (edited June 29, 2000).]