Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Byte Formatting

Status
Not open for further replies.

jfryer

Programmer
Sep 5, 2002
120
AU
Does anyone know of a way (or doco location) that will let me output bytes recieved over a comm line (serial) in binary format,

ie
recieved the number 8
output to screen 00001000 (or even 1000 will do).
recieved the letter a
output to screen 01100001

----------------------------------------
There are no onions, only magic
----------------------------------------
 
String java.math.BigInteger.toString( radix);

Good luck
-pete
 
I would use the toBinaryString method of the Integer class:

Code:
   class TestBinaryInt
           
   {
   
              
      public static void main(String Args[])
              
      {
         System.out.println(Integer.toBinaryString(8));
         System.out.println(Integer.toBinaryString('a'));
      }
   }

Hope that helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top