Hi
I have an array of float and i need to mask the values.
I want to be able to get arr[x] and arr[x+1] and then mask them and recombine them results in a radom order (im doing an evolutionary algorithm!)
But i cant get the masking to work, it always seems to return 1 as a reult.
This is the code that dosnt work:
for(x=size; x > 1; x--)
{
for(int y=0; y < 8; y++)
{
r = (int) (rand()%800);
if(r < 400)
{
chrom[y] = (float) population[x] && mask[y];
}//end if
if(r > 400)
{
chrom[y] = (float) population[x-1] && mask[y];
}//end if
nGen[x] = (float) chrom[0] || chrom[1] || chrom[2] ||
chrom[3] || chrom[4] || chrom[5] ||
chrom[6] || chrom[7];
} //end y
} // end x
mask[] is an arra of floats that stores the values I want to mask (as they need to be repeated through in order)
float mask[8] = { 0x0003, 0x0F0C, 0x0030, 0x00C0, 0x0300, 0x0C00, 0x3000, 0xC000 };
and chrom is where i want to store the incomplete values before ORing them together to make a complete float.
Any ideas on how to do the bitwise and with floats?? It just wont work!
Cheers.