私はこのような低レベルの操作に不慣れです。誰かが私がここで犯さなければならない明らかな間違いを指摘してくれることを望んでいます。
//Input value - 00111100
//I want to get the value of the bits at indexes 1-3 i.e 0111.
byte mask = (byte)0x00001111; // This gives 17 not the 15 I'd expect
byte shifted = (byte)(headerByte >> 3);
//shifted is 7 as expected
byte frameSizeValue = (byte)(shifted & mask); //Gives 1 not 7
問題はマスクの定義方法にあるようですが、修正方法がわかりません。