### Question:
HillCrestImuNode extends BuggyDecoratorNode implements DeviceListenerInterface, DiscoveryListenerInterface { protected double convertQNToDouble(int q, int n) { double qDouble = (double) q; int signBit = (q >> 15) & 0x1; int sign = 0; if (signBit == 0) { sign = 1; } else { sign = -1; } return sign * qDouble * Math.pow(2, -1 * n); } HillCrestImuNode(); @Override void handleRead(Device device, HidInMsg message, int i, long l); @Override void handleSend(Device device, HidOutMsg hidOutMsg, int i); @Override void notifyRemoved(Device device); @Override void freespaceDeviceInserted(Device device); @Override void freespaceDeviceRemoved(Device device);  }### Answer:
@Test public void testConvertQn() { int q1 = 53; int n1 = 2; double expected1 = 13.37; assertEquals(expected1, testNode.convertQNToDouble(q1, n1), 0.25); int q2 = 12868; int n2 = 12; double expected2 = 3.1417; assertEquals(expected2, testNode.convertQNToDouble(q2, n2), 0.0002); int q3 = 87; int n3 = 5; double expected3 = 2.7181; assertEquals(expected3, testNode.convertQNToDouble(q3, n3), 0.0312); int q4 = 69388; int n4 = 14; double expected4 = 4.2351; assertEquals(expected4, testNode.convertQNToDouble(q4, n4), 0.00006); int q5 = 3900; int n5 = 8; double expected5 = 15.2352; assertEquals(expected5, testNode.convertQNToDouble(q5, n5), 0.0039); int q6 = 0; int n6 = 10; double expected6 = 0.0; assertEquals(expected6, testNode.convertQNToDouble(q6, n6), 0.0); int q7 = 0x7FFF; int n7 = 1; double expected7 = 16383.5; assertEquals(expected7, testNode.convertQNToDouble(q7, n7), 0.0); int q8 = 0x8000; int n8 = 1; double expected8 = -16384.0; assertEquals(expected8, testNode.convertQNToDouble(q8, n8), 0.0); }