throw new RuntimeException("not implemented");
}
+ public static long signExtend(long val) {
+ if ((val & (1L << 36)) != 0)
+ val = val | (0xffffffffffffffffL << 36);
+ return val;
+ }
+
public long readWord() {
if (isTerminated())
throw new RuntimeException("this fleet has been terminated");
try {
- return queue.take();
+ return signExtend(queue.take());
} catch (InterruptedException e) { throw new RuntimeException(e); }
}
for(int i=0; i<6; i++) {
val = is.read();
if (val==-1) break;
- result |= ((long)val) << (i * 8);
+ long val2 = (val & 0xffL);
+ val2 = val2 << (i * 8);
+ result |= val2;
}
if (val==-1) break;
queue.put(result);