Depending on what you are doing, you can just treat long as a 64-bit value and int as a 32-bit value. Most operations esp readInt/Long writeInt/Long work just the same by ignoring the signness.
Can you give an example of operation you perform on these numbers and perhaps we can suggest how would do the same thing without having to expand the type.
For example, ++, --, +, -, *, ==, !=, << all work the same regardless of signess (i.e. give the same answer). for >> you can substitue >>>
It is the /, %, >, >=, <, <= and printing functions which assume signed values, but you should be able to work around these (if you use these).
e.g.
long unsignedA =
long unsignedB =
boolean greater = unsignedA + Long.MIN_VALUE > unsignedB + Long.MIN_VALUE
EDIT: Why does this work? Partly because java doesn't have overflow/underflow exceptions.
e.g.
byte unsignedA = 0;
unsignedA--;
// unsignedA == FF, is this -1 or 255? Java assumes the former but you assume the later
byte unsignedB = unsignedA * unsignedA;
// unsignedB is -1 * -1 = 1 or (byte) (255*255) = (byte) 65525 = 1.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…