Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html" rel="nofollow noreferrer"><code>ByteBuffer</code></a> works well for this: just put in 64 <code>long</code> values and get a <code>byte[]</code> out using the <code>array()</code> method. The <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/ByteOrder.html" rel="nofollow noreferrer"><code>ByteOrder</code></a> class can handle endian issues effectively. For example, incorporating the approach suggested in a comment by <a href="https://stackoverflow.com/users/136264/wierob">wierob</a>:</p> <pre><code>private static byte[] xform(long[] la, ByteOrder order) { ByteBuffer bb = ByteBuffer.allocate(la.length * 8); bb.order(order); bb.asLongBuffer().put(la); return bb.array(); } </code></pre> <p>Addendum: The resulting <code>byte[]</code> components are signed, 8-bit values, but Java arrays require <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-10.html" rel="nofollow noreferrer">nonnegative integer index values</a>. Casting a <code>byte</code> to an <code>int</code> will result in sign extension, but masking the higher order bits will give the unsigned value of <code>byte b</code>:</p> <pre><code>int i = (int) b &amp; 0xFF; </code></pre> <p>This <a href="https://stackoverflow.com/questions/2137690/java-operator-precedence-guidelines">answer</a> elaborates on the applicable operator precedence rules. This related <a href="https://stackoverflow.com/questions/5201422">answer</a> demonstrates a similar approach for <code>double</code> values.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload