I am trying to use an int to represent a register value. I need various parts of the number (in its binary form) to set the state for control lines etc.

My code works fine until I get to number 4096 at which points my boundaries stop behaving.

my boundaries are defined as follows:

```
bit 1 to bit 2, bit 3- bit 6, 7-11, 12-13, 14-n

```

I use the following code to convert the boundaries bits into integers:

```
public int getNToKBits(int leftMostBit, int rightMostBit){
    int subBits = (((1 << leftMostBit) - 1) & (value >> (rightMostBit - 1)));
    return subBits;
}

```

but when I try to split the number 4096 into these boundries I get the following:

```
b: 00, 10, 10000, 0000, 00
d:  0,  2,    64,    0,  0 

```

-I know, there aren't enough bits to make 64!!

what I expect is

```
b: 00, 10, 00000, 0000, 00
d:  0,  2,     0,    0,  0

```

It as expected with number less that 4096. Perhaps its a change in the way java treats numbers larger that 4096?