Memory dump which are in binary numbers would have many numbers of 0s and 1s. working with these numbers would be very difficult. Hence two number system hexadecimal and octal number system is used because these numbers are inter convertible with binary numbers by the concept of bits.
since bits are 0 & 1 in binary then 11111111 in binary = 256 in decimal = 377 in octal = FF in hexadecimal
There is no opposite. Decimal is one of many ways of representing numbers. The other ways: binary, octal, hexadecimal etc are equivalent alternatives, not opposites.
In binary this number is equivalent to 11111000011 while in octal it is 3703
In binary: 1111 1111 1111 1111 1111 1111 1111 1111 In octal: 37777777777 In hexadecimal: FFFFFFFF in decimal: 2³² - 1 = 4,294,967,295
The answer depends on what you are converting from: binary, ternary, octal, hexadecimal ...
Octal = 52746757 Binary = 101010111100110111101111
Octal and hexadecimal numbers are useful for humans as they compactly represent binary numbers:each octal digit represents exactly 3 binary digitseach hexadecimal number represents exactly 4 binary digitsFor example, instead of trying to read (and remember) the binary number 100111001001 it can be represented as hexadecimal 0x09c9 or octal 04711 which are easier to read (and remember) for humans.
Memory dump which are in binary numbers would have many numbers of 0s and 1s. working with these numbers would be very difficult. Hence two number system hexadecimal and octal number system is used because these numbers are inter convertible with binary numbers by the concept of bits.
221122: Binary = 1000100001000100100010 Octal = 10410442 Decimal = 2232610
import java.util.Scanner; public class NumberSystem { public void displayConversion() { Scanner input = new Scanner(System.in); System.out.printf("%-20s%-20s%-20s%-20s\n", "Decimal", "Binary", "Octal", "Hexadecimal"); for ( int i = 1; i <= 256; i++ ) { String binary = Integer.toBinaryString(i); String octal = Integer.toOctalString(i); String hexadecimal = Integer.toHexString(i); System.out.format("%-20d%-20s%-20s%-20s\n", i, binary, octal, hexadecimal); } } // returns a string representation of the decimal number in binary public String toBinaryString( int dec ) { String binary = " "; while (dec >= 1 ) { int value = dec % 2; binary = value + binary; dec /= 2; } return binary; } //returns a string representation of the number in octal public String toOctalString( int dec ) { String octal = " "; while ( dec >= 1 ) { int value = dec % 8; octal = value + octal; dec /= 8; } return octal; } public String toHexString( int dec ) { String hexadecimal = " "; while ( dec >= 1 ) { int value = dec % 16; switch (value) { case 10: hexadecimal = "A" + hexadecimal; break; case 11: hexadecimal = "B" + hexadecimal; break; case 12: hexadecimal = "C" + hexadecimal; break; case 13: hexadecimal = "D" + hexadecimal; break; case 14: hexadecimal = "E" + hexadecimal; break; case 15: hexadecimal = "F" + hexadecimal; break; default: hexadecimal = value + hexadecimal; break; } dec /= 16; } return hexadecimal; } public static void main( String args[]) { NumberSystem apps = new NumberSystem(); apps.displayConversion(); } }
Okay, I'm pretty sure that 864 binary is 30 hexadecimal. - RG
1
import java.util.Scanner; public class NumberSystem { public void displayConversion() { Scanner input = new Scanner(System.in); System.out.printf("%-20s%-20s%-20s%-20s\n", "Decimal", "Binary", "Octal", "Hexadecimal"); for ( int i = 1; i <= 256; i++ ) { String binary = Integer.toBinaryString(i); String octal = Integer.toOctalString(i); String hexadecimal = Integer.toHexString(i); System.out.format("%-20d%-20s%-20s%-20s\n", i, binary, octal, hexadecimal); } } // returns a string representation of the decimal number in binary public String toBinaryString( int dec ) { String binary = " "; while (dec >= 1 ) { int value = dec % 2; binary = value + binary; dec /= 2; } return binary; } //returns a string representation of the number in octal public String toOctalString( int dec ) { String octal = " "; while ( dec >= 1 ) { int value = dec % 8; octal = value + octal; dec /= 8; } return octal; } public String toHexString( int dec ) { String hexadecimal = " "; while ( dec >= 1 ) { int value = dec % 16; switch (value) { case 10: hexadecimal = "A" + hexadecimal; break; case 11: hexadecimal = "B" + hexadecimal; break; case 12: hexadecimal = "C" + hexadecimal; break; case 13: hexadecimal = "D" + hexadecimal; break; case 14: hexadecimal = "E" + hexadecimal; break; case 15: hexadecimal = "F" + hexadecimal; break; default: hexadecimal = value + hexadecimal; break; } dec /= 16; } return hexadecimal; } public static void main( String args[]) { NumberSystem apps = new NumberSystem(); apps.displayConversion(); } }
If the above is decimal then in hexadecimal it is 2964492C2. If it is binary then in hexadecimal it is 7DA. If it is octal then in hexadecimal it is 49241208.
Decimal, binary, octal and hexadecimal.
They are all different ways of representing numbers. For example the number 14 in binary would be 00001110, in octal it would be '16', and in hex would be represented by the '0E'