I need to convert symbols to bits so that every 2 symbols = 1 byte = 8 bits.
For example, if user input is RR then there should be 00001100 as result. (just an example)
I need to convert symbols to bits so that every 2 symbols = 1
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So, if I understood your question, there’re two options to resolve then: The easy or the hard way.
Easy:
Example:
Stores the result into a String
String ls_symbols = “AA”;
String ls_result = ” “;
for (int ln=0; ln < ls_symbols.lenght(); ln++) {
ls_result += lo_binary.get(ls_symbols.charAt(ln));
}
System.out.println(ls_result); // AA -> 10101010
Hard:
Example:
// Do you have a literal A. This literal represents in binary the value 1010. Do you have // use the operator >>> and & to change the binary value to boolean value