Skip to content

Latest commit

 

History

History
executable file
·
19 lines (18 loc) · 442 Bytes

Question5_1.md

File metadata and controls

executable file
·
19 lines (18 loc) · 442 Bytes

Question5_1

Solution

public class Question5_1 {
	public static int update(int m, int n, int j, int i){
		int allOnes = ~0;
		int left = allOnes << (j + 1);
		int right = ~(allOnes << i);
		int mask = left | right;
		int clearM = m & mask;
		int movedN = n << i;
		return clearM | movedN;
	}
	public static void main(String[] args) {
		System.out.println(Integer.toBinaryString(update(0B10000000000, 0B10011, 6, 2)));
	}
}