int n = /* some value */
int x = n | 0x1F; // 31
int n = /* some value */
int x = n | 0x20; // 32
int x = (n | 0x1F) + 1;
But, if you meant:int y = ( (( n & ~0x1F ) == n) ? n : (n | 0x1F) + 1);
int main(void)
{
int n;
for( n = 30; n<67; ++n ) {
int x = (n | 0x1F) + 1;
int y = ( (( n & ~0x1F ) == n) ? n : (n | 0x1F) + 1);
printf("%2d: x = %2d y = %2d\n", n, x, y);
}
}
OUTPUT:30: x = 32 y = 32
31: x = 32 y = 32
32: x = 64 y = 32
33: x = 64 y = 64
34: x = 64 y = 64
35: x = 64 y = 64
36: x = 64 y = 64
37: x = 64 y = 64
38: x = 64 y = 64
39: x = 64 y = 64
40: x = 64 y = 64
41: x = 64 y = 64
42: x = 64 y = 64
43: x = 64 y = 64
44: x = 64 y = 64
45: x = 64 y = 64
46: x = 64 y = 64
47: x = 64 y = 64
48: x = 64 y = 64
49: x = 64 y = 64
50: x = 64 y = 64
51: x = 64 y = 64
52: x = 64 y = 64
53: x = 64 y = 64
54: x = 64 y = 64
55: x = 64 y = 64
56: x = 64 y = 64
57: x = 64 y = 64
58: x = 64 y = 64
59: x = 64 y = 64
60: x = 64 y = 64
61: x = 64 y = 64
62: x = 64 y = 64
63: x = 64 y = 64
64: x = 96 y = 64
65: x = 96 y = 96
66: x = 96 y = 96
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
14 Experts available now in Live!