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

13
LINES

< > BotCompany Repo | #1035892 // byteArrayFromShorts_bigEndian

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

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

static byte[] byteArrayFromShorts_bigEndian(short[] a) {
  ret byteArrayFromShorts_bigEndian(a, 0, l(a));
}

static byte[] byteArrayFromShorts_bigEndian(short[] a, int from, int to) {
  byte[] b = new byte[(to-from)*2];
  for (int i = 0; i < a.length; i++) {
    short s = a[from+i];
    b[i*2] = (byte) (s >> 8);
    b[i*2+1] = (byte) s;
  }
  ret b;
}

Author comment

Began life as a copy of #1019649

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035892
Snippet name: byteArrayFromShorts_bigEndian
Eternal ID of this version: #1035892/1
Text MD5: d7197e75898ecfcf310ab00aeab1f188
Transpilation MD5: 1c49c1640ae7e1f93ddef31539012fee
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-08 16:13:11
Source code size: 365 bytes / 13 lines
Pitched / IR pitched: No / No
Views / Downloads: 77 / 100
Referenced in: [show references]