Results 1 to 2 of 2
  1. #1
    davidfla90 is offline Member
    Join Date
    Nov 2011
    Posts
    2
    Rep Power
    0

    Default Convert integer to binary then each binary character to boolean

    Hey,
    I need to convert an int, say 90, to a binary number (1011010), then i need to separate each digit and save it as a true or false boolean.
    (true, false, true, true, false, true, false).


    so far :

    String a;
    a = Integer.toBinaryString(int b);

    Any help is appreciated.

  2. #2
    eRaaaa is online now Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Convert integer to binary then each binary character to boolean

    all roads lead to Rome... do you have no idea?
    1. the boolean array must have the same size as the string -> boolean[] array = new boolean[a.length()];
    2. the string class has useful methods, like charAt(index) or toCharArray() to get each digit
    3. if the digit is == '1' -> save true in your boolean array on position 'index'

    or or or ...

Similar Threads

  1. convert integer to binary
    By leepikamukharji in forum New To Java
    Replies: 2
    Last Post: 04-30-2011, 04:19 AM
  2. convert interger value to binary value
    By ahmed80 in forum New To Java
    Replies: 6
    Last Post: 01-21-2011, 11:26 AM
  3. Replies: 12
    Last Post: 10-31-2010, 06:14 PM
  4. Convert Decimal To Binary
    By aspire007 in forum New To Java
    Replies: 8
    Last Post: 08-06-2010, 07:32 AM
  5. convert binary to images
    By fiqueudrue in forum New To Java
    Replies: 3
    Last Post: 02-12-2009, 09:16 AM

Tags for this Thread

Posting Permissions

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