Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

19
LINES

< > BotCompany Repo | #1036141 // byteArrayFromLongs_bigEndian

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (126L/1K).

static byte[] byteArrayFromLongs_bigEndian(long[] a) {
  ret byteArrayFromLongs_bigEndian(a, 0, l(a));
}

static byte[] byteArrayFromLongs_bigEndian(long[] a, int from, int to) {
  byte[] b = new byte[(to-from)*8];
  for (int i = 0; i < a.length; i++) {
    long s = a[from+i];
    b[i*8] = (byte) (s >> 56);
    b[i*8+1] = (byte) (s >> 48);
    b[i*8+2] = (byte) (s >> 40);
    b[i*8+3] = (byte) (s >> 32);
    b[i*8+4] = (byte) (s >> 24);
    b[i*8+5] = (byte) (s >> 16);
    b[i*8+6] = (byte) (s >> 8);
    b[i*8+7] = (byte) s;
  }
  ret b;
}

Author comment

Began life as a copy of #1035892

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036141
Snippet name: byteArrayFromLongs_bigEndian
Eternal ID of this version: #1036141/3
Text MD5: 3d54a1fa39820fba6d6a97a28a667118
Transpilation MD5: 0e111ccd637f117a95561afa7266387e
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-28 19:18:42
Source code size: 563 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 64 / 91
Version history: 2 change(s)
Referenced in: [show references]