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).

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

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: 168 / 226
Version history: 2 change(s)
Referenced in: [show references]