# Thread: [HELP] bit string confusion

1. Member
Join Date
Mar 2011
Posts
1
Rep Power
0

## [HELP] bit string confusion

Greetings..

I am tasked to convert numbers to bit strings to identify the differences of sets
my experimental Universal set is {1,2,3,4,5,6}. and my subset is {1,3,5}
if my Universal Set's strings would be "111111" my subset would be "101010"
for further explanation one means the element of the universal set is present to the sub set. zero means, that element of the universal set does not exist on the subset. This is my problem.
universal is the number of element of the universal set. in my experiment this is 6.
set1 is the number of element of the subset. in my experiment, it would be 3.
set1str array would be the storage for the bit string of my subset.
universe array is the universal set.
num1 array is the subset.

Java Code:
```int set1str[] = new int[universal];
for(int i=0; i<set1; i++)
{
for(int j=i; j<universal;j++)
{
if(universe[j]==num1[i])
{
System.out.print("1");
set1str[i] = 1;
j=universal;

}
else
System.out.print("0");
set1str[i] = 0;
}

}```
base on my experimental sets,
this code converts the bit string to 101001...
because 1(universal set) and 1(subset) in the if statement would print "1"
then end the nested loop.
on 2(universal set) and 3(subset) in the if statement would print "0"
on 3(universal set) and 3(subset) in the if statement would print "1"
on 3(universal set) and 5(subset) in the if statement would print "0"
on 4(universal set) and 5(subset) in the if statement would print "0"
on 5(universal set) and 5(subset) in the if statement would print "1"
then my code stops..
i should have 101010...

if this would be on the wrong section, i am sorry.., im just new here and because i made this code on eclipse, i posted it here on the eclipse section.

:(
:(
Last edited by Fubarable; 03-07-2011 at 05:42 PM.

2. Moderator actions:
• Code tags added. To see how to do this yourself, please click on the link in my signature below.
• Thread moved from Eclipse forum to the New to Java forum