I’d use:
if ((value & (1L << x)) != 0)
{
// The bit was set
}
(You may be able to get away with fewer brackets, but I never remember the precedence of bitwise operations.)
More Related Contents:
- How do I add an "L" to the end of an integer?
- Division of integers in Java [duplicate]
- Why do these two multiplication operations give different results?
- How do I convert Long to byte[] and back in java
- The literal xyz of type int is out of range
- Initialize a long in Java
- Converting Long to Date in Java returns 1970
- How do shift operators work in Java? [duplicate]
- Java’s L number (long) specification
- How can I check if multiplying two numbers in Java will cause an overflow?
- Java: random long number in 0
- Java: right shift on negative number
- Java “Bit Shifting” Tutorial? [closed]
- How to implement infinity in Java?
- How to convert a hexadecimal string to long in java?
- Java creating byte array whose size is represented by a long
- unsigned right Shift ‘>>>’ Operator in Java [duplicate]
- What does >> do in Java?
- Behaviour of unsigned right shift applied to byte variable
- Weird result of Java Integer left shift
- Convert Double to Binary representation?
- Why can’t your switch statement data type be long, Java?
- Wrong result by Java Math.pow
- Difference between >>> and >> operators [duplicate]
- (a * b) / c MulDiv and dealing with overflow from intermediate multiplication
- How do I convert from int to Long in Java?
- Loading context in Spring using web.xml
- Using variables outside of an if-statement
- Bounded-wildcard related compiler error
- Check if class exists in Java classpath without running its static initializer?