0

someone can help me to carry out a program of binary to hexadecimal are basic form arrangements I am new to this

estudio

19th Apr 2018, 5:51 PM
lel
5 Réponses
0
Each 4 bits of a byte(reading from the right) creates a digit of a hexadecimal character.
19th Apr 2018, 5:57 PM
Bebida Roja
Bebida Roja - avatar
0
but I do not know how to divide every four bits
19th Apr 2018, 6:02 PM
lel
0
You can parse binary strings to decimal int number = Integer.parseInt("101010", 2); String hexadecimal = Integer.toString(number, 16); System.out.println(hexadecimal ); Prints "2a"
19th Apr 2018, 6:30 PM
Toni Isotalo
Toni Isotalo - avatar
0
It does not come out, it marks me wrong. but thanks brother
19th Apr 2018, 6:41 PM
lel
0
divide binary number into groups of 4 bits, each group of 4 digits can have a possible value of between “0000” (0) and “1111” ( 8+4+2+1 = 15 ) giving a total of 16 different number combinations from 0 to 15. The numbers 0 to 9 are still decimals, but the numbers from 10 to 15 are represented by capital letters of the alphabet from A to F bin = 0011; while (bin > 0) { rem = bin % 2; dec = dec + rem * i; i = i * 2; bin = bin / 10; } i = 0; while (dec != 0) { hex[i] = dec % 16; dec = dec / 16; i++; } for (j = i - 1; j >= 0; j--) { if (hex[j] > 9) System.out.print((char)(hex[j] + 55)+"\n"); else System.out.print(hex[j]+"\n"); }
20th Apr 2018, 7:33 PM
Shaik Ruha Tabasum
Shaik Ruha Tabasum - avatar