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

23
LINES

< > BotCompany Repo | #1032435 // HalfLongs - array of 6-byte integers

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

Libraryless. Click here for Pure Java version (3255L/18K).

// an array of 6-byte integers
persistable sclass HalfLongs {
  short[] data;
  int length;
  
  *(int *length) {
    data = new short[safeToInt(length*3L)];
  }

  public int size() { ret length; }
  
  public void set(int i, long val) {
    data[i*3] = (short) val;
    data[i*3+1] = (short) (val >> 16);
    data[i*3+2] = (short) (val >> 32);
  }
  
  public long get(int i) {
    ret ushortToLong(data[i*3])
      | (ushortToLong(data[i*3+1]) << 16)
      | (data[i*3+2] << 32);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1032435
Snippet name: HalfLongs - array of 6-byte integers
Eternal ID of this version: #1032435/8
Text MD5: 3b80ca15e4e3e5aeb47949daff14d2f3
Transpilation MD5: 8e45aa9571c3fc35ac9b47ae306ece24
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-09-05 06:37:45
Source code size: 510 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 163 / 290
Version history: 7 change(s)
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)