I have thiselse clause:
else if (iItemIndex == 1 || iItemIndex == 3 || iItemIndex== 5 || iItemIndex == 7 ||
iItemIndex == 10 || iItemIndex == 12 || iItemIndex == 14 || iItemIndex == 16 ||
iItemIndex == 19 || iItemIndex == 21 || iItemIndex == 23 || iItemIndex == 25)
Can it be simplified in some way? Nothing wrong with the code. Just curious if there is a less verbose way of doing the test. In context I have:
if(iItemIndex == 0 || iItemIndex == 9 || iItemIndex == 18)
{
// Do something
}
else if (iItemIndex == 1 || iItemIndex == 3 || iItemIndex== 5 || iItemIndex == 7 ||
iItemIndex == 10 || iItemIndex == 12 || iItemIndex == 14 || iItemIndex == 16 ||
iItemIndex == 19 || iItemIndex == 21 || iItemIndex == 23 || iItemIndex == 25)
{
// Do something else
}
else
{
// Do something else
}
You can write
const bool rng=i>=0 && i<27;
if(const auto r=i%9; rng && !r) …
else if(rng && (r&1)) …
else …
This can of course be much simplified if the value may be assumed to be in the relevant range:
if(const auto r=i%9; !r) …
else if(r&1) …
else …
Related
The condition is that a product gets a discount if it is bought on september 15th through october 15th. How would I write an if statement for this?
You could start off with:
if ((month != 9 || month != 10) && (day....
I would say:
if (month == 9 && day >= 15) || (month == 10 && day <=15)
if((month == 9 && day >= 15) || (month == 10 && day <= 15)) { }
if ((month == 9 && day >= 15) || (month == 10 && day <= 15))
The goal is to optimize big condition expression by finding values dependencies between variables in order to reduce the logical OR statements.
Let's say we have the following condition:
if((A == 0 && B == 0) || (A == 0 && B == 1) || (A == 0 && B == 2) ...
a certain number of time...
Is there a way to reduce this kind of example by having automatically the following condition:
if(A == 0 && (B >= 0 && B <= 2))
The numbers involved in the first condition are only known just before the condition, it can't be typed manually. There can be also hundreds of logical OR operators involved in the condition. There can be gap between values (maybe use of % operator is needed) but there is always a pattern.
Any library or existing algorithm which can find the dependencies between the variables ?
Let's have another example:
if((A == 0 && B == 0) || (A == 0 && B == 2) || (A == 0 && B == 4)
can be translated to:
if((A == 0 && B%2 == 0)
One more:
if((A == 0 && B == 0 && C == 0) || (A == 0 && B == 2 && C == 0) || (A == 0 && B == 4 && C == 0) || (A == 0 && B == 0 && C == 1) || (A == 0 && B == 2 && C == 1) || (A == 0 && B == 4 && C == 1))
would be transformed into:
if(A==0 && B%2==0 && C>=0 && C<=1)
For the variables involved, I have all the values per terms.
I have something like [[0,0,0],[0,2,0],[0,4,0],[0,0,1],[0,2,1],[0,4,1]] (e.g. the last example)
Thanks for your time and answers !
if((A == 0 && B == 0) || (A == 0 && B == 2) || (A == 0 && B == 4)
cannot be translated to
if((A == 0 && B%2 == 0)
cuz
B == 6
and etc
Hello I am trying to learn c++ and I wanted to give a little practice with a program. However I'm having trouble using cout within the loop.
This is the loop I'm trying to output text from. When the user enters a number that isn't valid it is supposed to say "Sorry try again!"
while (datecheck)
{
bool check(false);
if (check)
std::cout<<"Sorry try again!"<<std::endl;
std::cin>>c;
if (c >= 1)
{
if (b == 2 && c <= 28)
datecheck = false;
if (b == 2 && a % 4 == 0 && c <= 29)
datecheck = false;
if (b == 4 || b == 6 || b == 9 || b == 11 && c <= 30)
datecheck = false;
if (c <= 31)
datecheck = false;
}
check = true;
}
When it outputs and I purposely keep myself in the loop it doesn't output anything
Year: -20
-20
-20
You declare a fresh new variable check at every iteration. And you initialize that variable to false every time. So move that declaration before the while loop.
Change this:
while (datecheck)
{
bool check(false);
...
check = true;
}
to this:
bool check(false);
while (datecheck)
{
...
check = true;
}
The problem is with declaration of bool check(false);. This keeps on re-assigning value to false at beginning of each iteration.
A simple fix could be to get-rid of use of check variable and use only datecheck.
bool datecheck(true);
while (true)
{
std::cin>>c;
if (c >= 1)
{
if (b == 2 && c <= 28)
datecheck = false;
if (b == 2 && a % 4 == 0 && c <= 29)
datecheck = false;
if (b == 4 || b == 6 || b == 9 || b == 11 && c <= 30)
datecheck = false;
if (c <= 31)
datecheck = false;
}
if (datecheck)
{
std::cout<<"Sorry try again!"<<std::endl;
}
else
{
break;
}
}
bool isValidDate(int month, int day, int year) {
if(year <= 1752){
if(month <= 9 && month <= 13){
return false;
}
else{
}
}
else{
if((month == 9 || month == 4 || month == 6 || month == 11) && (day <= 30)){
return true;
}
else if((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && (day <= 31)){
return true;
}
else if(isLeapYear(year)){
if((month == 2) && (day <= 29)){
return true;
}
}
else if(!isLeapYear(year)){
if((month == 2) && (day <= 28)){
return true;
}
}
else{
return false;
}
}
}
I'm trying to make it so that if users enter any date before Sept. 13, 1752, it will return false. And also if the days have to be correct according to the month while taking into account leap years for the month of February. But I keep getting an error. Help much needed.
I'm trying to write a shader that uses many bit operations. In fact they are supported since glsl 1.30, but I'm only on OpenGL 2.1.
Is there any way to use bit operations with my OpenGL version?
All SM3 compatible (~OpenGL 2.1) hardware supports limited integer functionality. This is usually done by emulating integers with floats and does not include bit operations.
For bit operations, you need either GLSL 1.3 or EXT_gpu_shader4.
If the reason that you have only OpenGL 2.1 is that your driver is somewhat outdated, you may be lucky to still have EXT_gpu_shader4 (updating drivers might be a good idea though, in that case).
If the reason is that your graphics card simply does not support anything better, you are out of luck.
If you do have EXT_gpu_shader4 (check extension string), you can add:
#extension EXT_gpu_shader4 : require
to your GLSL 1.2 shaders, and it should work.
This should help you get started.
lowp ivec4 imod4_2(lowp ivec4 x)
{
return x - (2 * (x/2));
}
lowp ivec4 parselowbits(lowp int x)
{
// Implement (x % y) where y is known to be the constant 2
// by first dividing x by (8, 4, 2, 1) and then doing a mod
// by (2, 2, 2, 2) to generate an int vector.
lowp ivec4 numerator = ivec4(x);
lowp ivec4 denominator = ivec4(8, 4, 2, 1);
lowp ivec4 modNumerator = numerator / denominator;
lowp ivec4 modResult = imod4_2(modNumerator);
return modResult;
}
lowp ivec4 parsehighbits(lowp int x)
{
// Implement (x % y) where y is known to be the constant 2
// by first dividing by (8*16, 4*16, 2*16, 1*16) and then doing a mod
// by (2, 2, 2, 2) to generate an int vector.
lowp ivec4 numerator = ivec4(x);
lowp ivec4 denominator = ivec4(8*16, 4*16, 2*16, 1*16);
lowp ivec4 modNumerator = numerator / denominator;
lowp ivec4 modResult = imod4_2(modNumerator);
return modResult;
}
The above functions work on the high a low nibble (4 bits) of a component like .r .g of an input vector. You will of course need to read values in and multiply by 255 to denormalize. Then, implementing AND is easy:
lowp ivec4 and4(lowp ivec4 a, lowp ivec4 b)
{
lowp ivec4 a_and_b = a * b;
return a_and_b;
}
If you want bitwise AND (A & B) == B, here's a really dumb solution that works (up to values of 255):
bool bitMaskCheck(float value, float check){
return (check == 1.0 &&
(value == 1.0 ||
value == 3.0 ||
value == 5.0 ||
value == 7.0 ||
value == 9.0 ||
value == 11.0 ||
value == 13.0 ||
value == 15.0 ||
value == 17.0 ||
value == 19.0 ||
value == 21.0 ||
value == 23.0 ||
value == 25.0 ||
value == 27.0 ||
value == 29.0 ||
value == 31.0 ||
value == 33.0 ||
value == 35.0 ||
value == 37.0 ||
value == 39.0 ||
value == 41.0 ||
value == 43.0 ||
value == 45.0 ||
value == 47.0 ||
value == 49.0 ||
value == 51.0 ||
value == 53.0 ||
value == 55.0 ||
value == 57.0 ||
value == 59.0 ||
value == 61.0 ||
value == 63.0 ||
value == 65.0 ||
value == 67.0 ||
value == 69.0 ||
value == 71.0 ||
value == 73.0 ||
value == 75.0 ||
value == 77.0 ||
value == 79.0 ||
value == 81.0 ||
value == 83.0 ||
value == 85.0 ||
value == 87.0 ||
value == 89.0 ||
value == 91.0 ||
value == 93.0 ||
value == 95.0 ||
value == 97.0 ||
value == 99.0 ||
value == 101.0 ||
value == 103.0 ||
value == 105.0 ||
value == 107.0 ||
value == 109.0 ||
value == 111.0 ||
value == 113.0 ||
value == 115.0 ||
value == 117.0 ||
value == 119.0 ||
value == 121.0 ||
value == 123.0 ||
value == 125.0 ||
value == 127.0 ||
value == 129.0 ||
value == 131.0 ||
value == 133.0 ||
value == 135.0 ||
value == 137.0 ||
value == 139.0 ||
value == 141.0 ||
value == 143.0 ||
value == 145.0 ||
value == 147.0 ||
value == 149.0 ||
value == 151.0 ||
value == 153.0 ||
value == 155.0 ||
value == 157.0 ||
value == 159.0 ||
value == 161.0 ||
value == 163.0 ||
value == 165.0 ||
value == 167.0 ||
value == 169.0 ||
value == 171.0 ||
value == 173.0 ||
value == 175.0 ||
value == 177.0 ||
value == 179.0 ||
value == 181.0 ||
value == 183.0 ||
value == 185.0 ||
value == 187.0 ||
value == 189.0 ||
value == 191.0 ||
value == 193.0 ||
value == 195.0 ||
value == 197.0 ||
value == 199.0 ||
value == 201.0 ||
value == 203.0 ||
value == 205.0 ||
value == 207.0 ||
value == 209.0 ||
value == 211.0 ||
value == 213.0 ||
value == 215.0 ||
value == 217.0 ||
value == 219.0 ||
value == 221.0 ||
value == 223.0 ||
value == 225.0 ||
value == 227.0 ||
value == 229.0 ||
value == 231.0 ||
value == 233.0 ||
value == 235.0 ||
value == 237.0 ||
value == 239.0 ||
value == 241.0 ||
value == 243.0 ||
value == 245.0 ||
value == 247.0 ||
value == 249.0 ||
value == 251.0 ||
value == 253.0 ||
value == 255.0)) ||
(check == 2.0 &&
(value == 2.0 ||
value == 3.0 ||
value == 6.0 ||
value == 7.0 ||
value == 10.0 ||
value == 11.0 ||
value == 14.0 ||
value == 15.0 ||
value == 18.0 ||
value == 19.0 ||
value == 22.0 ||
value == 23.0 ||
value == 26.0 ||
value == 27.0 ||
value == 30.0 ||
value == 31.0 ||
value == 34.0 ||
value == 35.0 ||
value == 38.0 ||
value == 39.0 ||
value == 42.0 ||
value == 43.0 ||
value == 46.0 ||
value == 47.0 ||
value == 50.0 ||
value == 51.0 ||
value == 54.0 ||
value == 55.0 ||
value == 58.0 ||
value == 59.0 ||
value == 62.0 ||
value == 63.0 ||
value == 66.0 ||
value == 67.0 ||
value == 70.0 ||
value == 71.0 ||
value == 74.0 ||
value == 75.0 ||
value == 78.0 ||
value == 79.0 ||
value == 82.0 ||
value == 83.0 ||
value == 86.0 ||
value == 87.0 ||
value == 90.0 ||
value == 91.0 ||
value == 94.0 ||
value == 95.0 ||
value == 98.0 ||
value == 99.0 ||
value == 102.0 ||
value == 103.0 ||
value == 106.0 ||
value == 107.0 ||
value == 110.0 ||
value == 111.0 ||
value == 114.0 ||
value == 115.0 ||
value == 118.0 ||
value == 119.0 ||
value == 122.0 ||
value == 123.0 ||
value == 126.0 ||
value == 127.0 ||
value == 130.0 ||
value == 131.0 ||
value == 134.0 ||
value == 135.0 ||
value == 138.0 ||
value == 139.0 ||
value == 142.0 ||
value == 143.0 ||
value == 146.0 ||
value == 147.0 ||
value == 150.0 ||
value == 151.0 ||
value == 154.0 ||
value == 155.0 ||
value == 158.0 ||
value == 159.0 ||
value == 162.0 ||
value == 163.0 ||
value == 166.0 ||
value == 167.0 ||
value == 170.0 ||
value == 171.0 ||
value == 174.0 ||
value == 175.0 ||
value == 178.0 ||
value == 179.0 ||
value == 182.0 ||
value == 183.0 ||
value == 186.0 ||
value == 187.0 ||
value == 190.0 ||
value == 191.0 ||
value == 194.0 ||
value == 195.0 ||
value == 198.0 ||
value == 199.0 ||
value == 202.0 ||
value == 203.0 ||
value == 206.0 ||
value == 207.0 ||
value == 210.0 ||
value == 211.0 ||
value == 214.0 ||
value == 215.0 ||
value == 218.0 ||
value == 219.0 ||
value == 222.0 ||
value == 223.0 ||
value == 226.0 ||
value == 227.0 ||
value == 230.0 ||
value == 231.0 ||
value == 234.0 ||
value == 235.0 ||
value == 238.0 ||
value == 239.0 ||
value == 242.0 ||
value == 243.0 ||
value == 246.0 ||
value == 247.0 ||
value == 250.0 ||
value == 251.0 ||
value == 254.0 ||
value == 255.0)) ||
(check == 4.0 &&
(value == 4.0 ||
value == 5.0 ||
value == 6.0 ||
value == 7.0 ||
value == 12.0 ||
value == 13.0 ||
value == 14.0 ||
value == 15.0 ||
value == 20.0 ||
value == 21.0 ||
value == 22.0 ||
value == 23.0 ||
value == 28.0 ||
value == 29.0 ||
value == 30.0 ||
value == 31.0 ||
value == 36.0 ||
value == 37.0 ||
value == 38.0 ||
value == 39.0 ||
value == 44.0 ||
value == 45.0 ||
value == 46.0 ||
value == 47.0 ||
value == 52.0 ||
value == 53.0 ||
value == 54.0 ||
value == 55.0 ||
value == 60.0 ||
value == 61.0 ||
value == 62.0 ||
value == 63.0 ||
value == 68.0 ||
value == 69.0 ||
value == 70.0 ||
value == 71.0 ||
value == 76.0 ||
value == 77.0 ||
value == 78.0 ||
value == 79.0 ||
value == 84.0 ||
value == 85.0 ||
value == 86.0 ||
value == 87.0 ||
value == 92.0 ||
value == 93.0 ||
value == 94.0 ||
value == 95.0 ||
value == 100.0 ||
value == 101.0 ||
value == 102.0 ||
value == 103.0 ||
value == 108.0 ||
value == 109.0 ||
value == 110.0 ||
value == 111.0 ||
value == 116.0 ||
value == 117.0 ||
value == 118.0 ||
value == 119.0 ||
value == 124.0 ||
value == 125.0 ||
value == 126.0 ||
value == 127.0 ||
value == 132.0 ||
value == 133.0 ||
value == 134.0 ||
value == 135.0 ||
value == 140.0 ||
value == 141.0 ||
value == 142.0 ||
value == 143.0 ||
value == 148.0 ||
value == 149.0 ||
value == 150.0 ||
value == 151.0 ||
value == 156.0 ||
value == 157.0 ||
value == 158.0 ||
value == 159.0 ||
value == 164.0 ||
value == 165.0 ||
value == 166.0 ||
value == 167.0 ||
value == 172.0 ||
value == 173.0 ||
value == 174.0 ||
value == 175.0 ||
value == 180.0 ||
value == 181.0 ||
value == 182.0 ||
value == 183.0 ||
value == 188.0 ||
value == 189.0 ||
value == 190.0 ||
value == 191.0 ||
value == 196.0 ||
value == 197.0 ||
value == 198.0 ||
value == 199.0 ||
value == 204.0 ||
value == 205.0 ||
value == 206.0 ||
value == 207.0 ||
value == 212.0 ||
value == 213.0 ||
value == 214.0 ||
value == 215.0 ||
value == 220.0 ||
value == 221.0 ||
value == 222.0 ||
value == 223.0 ||
value == 228.0 ||
value == 229.0 ||
value == 230.0 ||
value == 231.0 ||
value == 236.0 ||
value == 237.0 ||
value == 238.0 ||
value == 239.0 ||
value == 244.0 ||
value == 245.0 ||
value == 246.0 ||
value == 247.0 ||
value == 252.0 ||
value == 253.0 ||
value == 254.0 ||
value == 255.0)) ||
(check == 8.0 &&
(value == 8.0 ||
value == 9.0 ||
value == 10.0 ||
value == 11.0 ||
value == 12.0 ||
value == 13.0 ||
value == 14.0 ||
value == 15.0 ||
value == 24.0 ||
value == 25.0 ||
value == 26.0 ||
value == 27.0 ||
value == 28.0 ||
value == 29.0 ||
value == 30.0 ||
value == 31.0 ||
value == 40.0 ||
value == 41.0 ||
value == 42.0 ||
value == 43.0 ||
value == 44.0 ||
value == 45.0 ||
value == 46.0 ||
value == 47.0 ||
value == 56.0 ||
value == 57.0 ||
value == 58.0 ||
value == 59.0 ||
value == 60.0 ||
value == 61.0 ||
value == 62.0 ||
value == 63.0 ||
value == 72.0 ||
value == 73.0 ||
value == 74.0 ||
value == 75.0 ||
value == 76.0 ||
value == 77.0 ||
value == 78.0 ||
value == 79.0 ||
value == 88.0 ||
value == 89.0 ||
value == 90.0 ||
value == 91.0 ||
value == 92.0 ||
value == 93.0 ||
value == 94.0 ||
value == 95.0 ||
value == 104.0 ||
value == 105.0 ||
value == 106.0 ||
value == 107.0 ||
value == 108.0 ||
value == 109.0 ||
value == 110.0 ||
value == 111.0 ||
value == 120.0 ||
value == 121.0 ||
value == 122.0 ||
value == 123.0 ||
value == 124.0 ||
value == 125.0 ||
value == 126.0 ||
value == 127.0 ||
value == 136.0 ||
value == 137.0 ||
value == 138.0 ||
value == 139.0 ||
value == 140.0 ||
value == 141.0 ||
value == 142.0 ||
value == 143.0 ||
value == 152.0 ||
value == 153.0 ||
value == 154.0 ||
value == 155.0 ||
value == 156.0 ||
value == 157.0 ||
value == 158.0 ||
value == 159.0 ||
value == 168.0 ||
value == 169.0 ||
value == 170.0 ||
value == 171.0 ||
value == 172.0 ||
value == 173.0 ||
value == 174.0 ||
value == 175.0 ||
value == 184.0 ||
value == 185.0 ||
value == 186.0 ||
value == 187.0 ||
value == 188.0 ||
value == 189.0 ||
value == 190.0 ||
value == 191.0 ||
value == 200.0 ||
value == 201.0 ||
value == 202.0 ||
value == 203.0 ||
value == 204.0 ||
value == 205.0 ||
value == 206.0 ||
value == 207.0 ||
value == 216.0 ||
value == 217.0 ||
value == 218.0 ||
value == 219.0 ||
value == 220.0 ||
value == 221.0 ||
value == 222.0 ||
value == 223.0 ||
value == 232.0 ||
value == 233.0 ||
value == 234.0 ||
value == 235.0 ||
value == 236.0 ||
value == 237.0 ||
value == 238.0 ||
value == 239.0 ||
value == 248.0 ||
value == 249.0 ||
value == 250.0 ||
value == 251.0 ||
value == 252.0 ||
value == 253.0 ||
value == 254.0 ||
value == 255.0)) ||
(check == 16.0 &&
(value == 16.0 ||
value == 17.0 ||
value == 18.0 ||
value == 19.0 ||
value == 20.0 ||
value == 21.0 ||
value == 22.0 ||
value == 23.0 ||
value == 24.0 ||
value == 25.0 ||
value == 26.0 ||
value == 27.0 ||
value == 28.0 ||
value == 29.0 ||
value == 30.0 ||
value == 31.0 ||
value == 48.0 ||
value == 49.0 ||
value == 50.0 ||
value == 51.0 ||
value == 52.0 ||
value == 53.0 ||
value == 54.0 ||
value == 55.0 ||
value == 56.0 ||
value == 57.0 ||
value == 58.0 ||
value == 59.0 ||
value == 60.0 ||
value == 61.0 ||
value == 62.0 ||
value == 63.0 ||
value == 80.0 ||
value == 81.0 ||
value == 82.0 ||
value == 83.0 ||
value == 84.0 ||
value == 85.0 ||
value == 86.0 ||
value == 87.0 ||
value == 88.0 ||
value == 89.0 ||
value == 90.0 ||
value == 91.0 ||
value == 92.0 ||
value == 93.0 ||
value == 94.0 ||
value == 95.0 ||
value == 112.0 ||
value == 113.0 ||
value == 114.0 ||
value == 115.0 ||
value == 116.0 ||
value == 117.0 ||
value == 118.0 ||
value == 119.0 ||
value == 120.0 ||
value == 121.0 ||
value == 122.0 ||
value == 123.0 ||
value == 124.0 ||
value == 125.0 ||
value == 126.0 ||
value == 127.0 ||
value == 144.0 ||
value == 145.0 ||
value == 146.0 ||
value == 147.0 ||
value == 148.0 ||
value == 149.0 ||
value == 150.0 ||
value == 151.0 ||
value == 152.0 ||
value == 153.0 ||
value == 154.0 ||
value == 155.0 ||
value == 156.0 ||
value == 157.0 ||
value == 158.0 ||
value == 159.0 ||
value == 176.0 ||
value == 177.0 ||
value == 178.0 ||
value == 179.0 ||
value == 180.0 ||
value == 181.0 ||
value == 182.0 ||
value == 183.0 ||
value == 184.0 ||
value == 185.0 ||
value == 186.0 ||
value == 187.0 ||
value == 188.0 ||
value == 189.0 ||
value == 190.0 ||
value == 191.0 ||
value == 208.0 ||
value == 209.0 ||
value == 210.0 ||
value == 211.0 ||
value == 212.0 ||
value == 213.0 ||
value == 214.0 ||
value == 215.0 ||
value == 216.0 ||
value == 217.0 ||
value == 218.0 ||
value == 219.0 ||
value == 220.0 ||
value == 221.0 ||
value == 222.0 ||
value == 223.0 ||
value == 240.0 ||
value == 241.0 ||
value == 242.0 ||
value == 243.0 ||
value == 244.0 ||
value == 245.0 ||
value == 246.0 ||
value == 247.0 ||
value == 248.0 ||
value == 249.0 ||
value == 250.0 ||
value == 251.0 ||
value == 252.0 ||
value == 253.0 ||
value == 254.0 ||
value == 255.0)) ||
(check == 32.0 &&
(value == 32.0 ||
value == 33.0 ||
value == 34.0 ||
value == 35.0 ||
value == 36.0 ||
value == 37.0 ||
value == 38.0 ||
value == 39.0 ||
value == 40.0 ||
value == 41.0 ||
value == 42.0 ||
value == 43.0 ||
value == 44.0 ||
value == 45.0 ||
value == 46.0 ||
value == 47.0 ||
value == 48.0 ||
value == 49.0 ||
value == 50.0 ||
value == 51.0 ||
value == 52.0 ||
value == 53.0 ||
value == 54.0 ||
value == 55.0 ||
value == 56.0 ||
value == 57.0 ||
value == 58.0 ||
value == 59.0 ||
value == 60.0 ||
value == 61.0 ||
value == 62.0 ||
value == 63.0 ||
value == 96.0 ||
value == 97.0 ||
value == 98.0 ||
value == 99.0 ||
value == 100.0 ||
value == 101.0 ||
value == 102.0 ||
value == 103.0 ||
value == 104.0 ||
value == 105.0 ||
value == 106.0 ||
value == 107.0 ||
value == 108.0 ||
value == 109.0 ||
value == 110.0 ||
value == 111.0 ||
value == 112.0 ||
value == 113.0 ||
value == 114.0 ||
value == 115.0 ||
value == 116.0 ||
value == 117.0 ||
value == 118.0 ||
value == 119.0 ||
value == 120.0 ||
value == 121.0 ||
value == 122.0 ||
value == 123.0 ||
value == 124.0 ||
value == 125.0 ||
value == 126.0 ||
value == 127.0 ||
value == 160.0 ||
value == 161.0 ||
value == 162.0 ||
value == 163.0 ||
value == 164.0 ||
value == 165.0 ||
value == 166.0 ||
value == 167.0 ||
value == 168.0 ||
value == 169.0 ||
value == 170.0 ||
value == 171.0 ||
value == 172.0 ||
value == 173.0 ||
value == 174.0 ||
value == 175.0 ||
value == 176.0 ||
value == 177.0 ||
value == 178.0 ||
value == 179.0 ||
value == 180.0 ||
value == 181.0 ||
value == 182.0 ||
value == 183.0 ||
value == 184.0 ||
value == 185.0 ||
value == 186.0 ||
value == 187.0 ||
value == 188.0 ||
value == 189.0 ||
value == 190.0 ||
value == 191.0 ||
value == 224.0 ||
value == 225.0 ||
value == 226.0 ||
value == 227.0 ||
value == 228.0 ||
value == 229.0 ||
value == 230.0 ||
value == 231.0 ||
value == 232.0 ||
value == 233.0 ||
value == 234.0 ||
value == 235.0 ||
value == 236.0 ||
value == 237.0 ||
value == 238.0 ||
value == 239.0 ||
value == 240.0 ||
value == 241.0 ||
value == 242.0 ||
value == 243.0 ||
value == 244.0 ||
value == 245.0 ||
value == 246.0 ||
value == 247.0 ||
value == 248.0 ||
value == 249.0 ||
value == 250.0 ||
value == 251.0 ||
value == 252.0 ||
value == 253.0 ||
value == 254.0 ||
value == 255.0)) ||
(check == 64.0 &&
(value == 64.0 ||
value == 65.0 ||
value == 66.0 ||
value == 67.0 ||
value == 68.0 ||
value == 69.0 ||
value == 70.0 ||
value == 71.0 ||
value == 72.0 ||
value == 73.0 ||
value == 74.0 ||
value == 75.0 ||
value == 76.0 ||
value == 77.0 ||
value == 78.0 ||
value == 79.0 ||
value == 80.0 ||
value == 81.0 ||
value == 82.0 ||
value == 83.0 ||
value == 84.0 ||
value == 85.0 ||
value == 86.0 ||
value == 87.0 ||
value == 88.0 ||
value == 89.0 ||
value == 90.0 ||
value == 91.0 ||
value == 92.0 ||
value == 93.0 ||
value == 94.0 ||
value == 95.0 ||
value == 96.0 ||
value == 97.0 ||
value == 98.0 ||
value == 99.0 ||
value == 100.0 ||
value == 101.0 ||
value == 102.0 ||
value == 103.0 ||
value == 104.0 ||
value == 105.0 ||
value == 106.0 ||
value == 107.0 ||
value == 108.0 ||
value == 109.0 ||
value == 110.0 ||
value == 111.0 ||
value == 112.0 ||
value == 113.0 ||
value == 114.0 ||
value == 115.0 ||
value == 116.0 ||
value == 117.0 ||
value == 118.0 ||
value == 119.0 ||
value == 120.0 ||
value == 121.0 ||
value == 122.0 ||
value == 123.0 ||
value == 124.0 ||
value == 125.0 ||
value == 126.0 ||
value == 127.0 ||
value == 192.0 ||
value == 193.0 ||
value == 194.0 ||
value == 195.0 ||
value == 196.0 ||
value == 197.0 ||
value == 198.0 ||
value == 199.0 ||
value == 200.0 ||
value == 201.0 ||
value == 202.0 ||
value == 203.0 ||
value == 204.0 ||
value == 205.0 ||
value == 206.0 ||
value == 207.0 ||
value == 208.0 ||
value == 209.0 ||
value == 210.0 ||
value == 211.0 ||
value == 212.0 ||
value == 213.0 ||
value == 214.0 ||
value == 215.0 ||
value == 216.0 ||
value == 217.0 ||
value == 218.0 ||
value == 219.0 ||
value == 220.0 ||
value == 221.0 ||
value == 222.0 ||
value == 223.0 ||
value == 224.0 ||
value == 225.0 ||
value == 226.0 ||
value == 227.0 ||
value == 228.0 ||
value == 229.0 ||
value == 230.0 ||
value == 231.0 ||
value == 232.0 ||
value == 233.0 ||
value == 234.0 ||
value == 235.0 ||
value == 236.0 ||
value == 237.0 ||
value == 238.0 ||
value == 239.0 ||
value == 240.0 ||
value == 241.0 ||
value == 242.0 ||
value == 243.0 ||
value == 244.0 ||
value == 245.0 ||
value == 246.0 ||
value == 247.0 ||
value == 248.0 ||
value == 249.0 ||
value == 250.0 ||
value == 251.0 ||
value == 252.0 ||
value == 253.0 ||
value == 254.0 ||
value == 255.0)) ||
(check == 128.0 &&
(value == 128.0 ||
value == 129.0 ||
value == 130.0 ||
value == 131.0 ||
value == 132.0 ||
value == 133.0 ||
value == 134.0 ||
value == 135.0 ||
value == 136.0 ||
value == 137.0 ||
value == 138.0 ||
value == 139.0 ||
value == 140.0 ||
value == 141.0 ||
value == 142.0 ||
value == 143.0 ||
value == 144.0 ||
value == 145.0 ||
value == 146.0 ||
value == 147.0 ||
value == 148.0 ||
value == 149.0 ||
value == 150.0 ||
value == 151.0 ||
value == 152.0 ||
value == 153.0 ||
value == 154.0 ||
value == 155.0 ||
value == 156.0 ||
value == 157.0 ||
value == 158.0 ||
value == 159.0 ||
value == 160.0 ||
value == 161.0 ||
value == 162.0 ||
value == 163.0 ||
value == 164.0 ||
value == 165.0 ||
value == 166.0 ||
value == 167.0 ||
value == 168.0 ||
value == 169.0 ||
value == 170.0 ||
value == 171.0 ||
value == 172.0 ||
value == 173.0 ||
value == 174.0 ||
value == 175.0 ||
value == 176.0 ||
value == 177.0 ||
value == 178.0 ||
value == 179.0 ||
value == 180.0 ||
value == 181.0 ||
value == 182.0 ||
value == 183.0 ||
value == 184.0 ||
value == 185.0 ||
value == 186.0 ||
value == 187.0 ||
value == 188.0 ||
value == 189.0 ||
value == 190.0 ||
value == 191.0 ||
value == 192.0 ||
value == 193.0 ||
value == 194.0 ||
value == 195.0 ||
value == 196.0 ||
value == 197.0 ||
value == 198.0 ||
value == 199.0 ||
value == 200.0 ||
value == 201.0 ||
value == 202.0 ||
value == 203.0 ||
value == 204.0 ||
value == 205.0 ||
value == 206.0 ||
value == 207.0 ||
value == 208.0 ||
value == 209.0 ||
value == 210.0 ||
value == 211.0 ||
value == 212.0 ||
value == 213.0 ||
value == 214.0 ||
value == 215.0 ||
value == 216.0 ||
value == 217.0 ||
value == 218.0 ||
value == 219.0 ||
value == 220.0 ||
value == 221.0 ||
value == 222.0 ||
value == 223.0 ||
value == 224.0 ||
value == 225.0 ||
value == 226.0 ||
value == 227.0 ||
value == 228.0 ||
value == 229.0 ||
value == 230.0 ||
value == 231.0 ||
value == 232.0 ||
value == 233.0 ||
value == 234.0 ||
value == 235.0 ||
value == 236.0 ||
value == 237.0 ||
value == 238.0 ||
value == 239.0 ||
value == 240.0 ||
value == 241.0 ||
value == 242.0 ||
value == 243.0 ||
value == 244.0 ||
value == 245.0 ||
value == 246.0 ||
value == 247.0 ||
value == 248.0 ||
value == 249.0 ||
value == 250.0 ||
value == 251.0 ||
value == 252.0 ||
value == 253.0 ||
value == 254.0 ||
value == 255.0));
}
// Usage
// 0b10000
#define MY_BITWISE 16
// 0b10101
float someValue = 21;
if(bitMaskCheck(someValue, MY_BITWISE)){
// some logic here
}
// This is the same as (someValue & MY_BITWISE) == MY_BITWISE