Results 1 to 5 of 5

Thread: how to translate letters to binary values?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    15

    Question how to translate letters to binary values?

    Hi people,
    I am very new to code writing and seeking for immidiate help How do I translate binary values to alphabet or the other way around?
    class Binary {
    public static void main(String args[])
    throws java.io.IOException{

    // I guess I have to define very single binray value.
    // for example:
    int i = 1000001, j = 1100001; //etc.
    // and do the same thing for letters.
    char ch = 'A', ch1 = 'a'; //etc..

    //the question is how can I assign i = ch and j = ch1 ? in order to display the value of the entered binary code.. Don't laugh people

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: how to translate letters to binary values?

    Try this : char ch = (char)128; ( http://www.vbforums.com/showthread.php?t=257927 )

    It doesn't need to be in binary.

    Also : http://www.vbforums.com/showthread.php?t=25045


    Has someone helped you? Then you can Rate their helpful post.

  3. #3
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: how to translate letters to binary values?

    use getBytes(), then convert each byte to an int, then use the static toBinaryString() method to get the equivalent binary string.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: how to translate letters to binary values?

    Also note that this:
    int i = 1000001
    is not binary.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    15

    Re: how to translate letters to binary values?

    Quote Originally Posted by System_Error
    use getBytes(), then convert each byte to an int, then use the static toBinaryString() method to get the equivalent binary string.
    Hi there, Do you think I am on the right track.
    class Binary {
    public void getBytes(byte dst[]) or should I use public byte[] getBytes(String enc) throws UnsupportedEncodingException
    public static String toBinaryString(int i)

    Thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width