My question is whether I can only switch bits B6, B5 to create a toUpper() function or if I would need to split the bits into separate parts
An example shift of this type would be:
1000001 to 1100001 (A to a)
My question is whether I can only switch bits B6, B5 to create a toUpper() function or if I would need to split the bits into separate parts
An example shift of this type would be:
1000001 to 1100001 (A to a)
You can shift just one bit using masking but there is a much simpler way.
if ('a' <= ch && ch <= 'z')
ch -= 'a' - 'A'; // subtract 32
public static final int BIT5 = 0x20;
int A = 0b1000001;
int a = setBits(A, BIT5);
public static int setBits(int val, int bits) {
return val | bits;
}
public static int clearBits(int val, int bits) {
return val & ~bits;
}