I have a binary code originated from bitse<16>binary_form (decimal_form)
. I want to check if the output code is 0010********1001
or 1001********0010
or 1001********0001
. So i want to check the value of the first half byte and the value of the last half byte. I used if &if else
statements but i am searching for more professional way to perform this check rather than check every bit.
Here is what i tried :
if(binary_form[0]==1&& binary_form[1]==0&& binary_form[2]==0&& binary_form[3]==1 &&binary_form[12]==0 &&binary_form[13]==1 &&binary_form[14]==0 &&binary_form[15]==0)
{
cout<<"Jhon\n";
}
else if(binary_form[0]==0 &&binary_form[1]==1 &&binary_form[2]==0 &&binary_form[3]==0 &&binary_form[12]==1 &&binary_form[13]==0 &&binary_form[14]==0&& binary_form[15]==1)
{
cout<<"Remon\n";
}
else if(binary_form[0]==1 &&binary_form[1]==0 &&binary_form[2]==0 && binary_form[3]==0 &&binary_form[12]==1 &&binary_form[13]==0 &&binary_form[14]==0 && binary_form[15]==1)
{
cout<<"Soliman\n";
}
The bits marked with (*) are not necessary for my check.