Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting a character to its binary value [duplicate]

Tags:

java

how can I get the binary value of a character Ex: Letter C (ASCII Code= 067) To Binary value 01000011.

like image 411
Ruru Morlano Avatar asked Mar 25 '13 02:03

Ruru Morlano


People also ask

How to convert character to binary?

To calculate the number value of a binary number, add up the value for each position of all the 1s in the eight character number. The number 01000001, for example, is converted to 64 + 1 or 65.

How to convert a binary into a string?

The naive approach is to convert the given binary data in decimal by taking the sum of binary digits (dn) times their power of 2*(2^n). The binary data is divided into sets of 7 bits because this set of binary as input, returns the corresponding decimal value which is ASCII code of the character of a string.

How do you convert int to binary in Python?

To convert int to binary in Python, use the bin() method. The bin() is a built-in Python method that converts a decimal to a binary data type. The bin() function accepts a number as an argument and returns its equivalent binary string prefixed with “0b”.


1 Answers

Use Integer.toBinaryString(character...);

like image 177
Anthony Raimondo Avatar answered Oct 01 '22 08:10

Anthony Raimondo