Libraryless. Click here for Pure Java version (2515L/16K).
1 | static byte[] compress30BitUint(int i) { |
2 | if (i < 0 || i >= 0x40000000) fail("Not a 30 bit uint: " + i); |
3 | if (i < 0x40) |
4 | ret new byte[] { (byte) i }; |
5 | if (i < 0x4000) |
6 | ret new byte[] { |
7 | (byte) ((i >> 8) | 0x40), |
8 | (byte) i |
9 | }; |
10 | if (i < 0x400000) |
11 | ret new byte[] { |
12 | (byte) ((i >> 16) | 0x80), |
13 | (byte) (i >> 8), |
14 | (byte) i |
15 | }; |
16 | ret new byte[] { |
17 | (byte) ((i >> 24) | 0xC0), |
18 | (byte) (i >> 16), |
19 | (byte) (i >> 8), |
20 | (byte) i |
21 | }; |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029522 |
Snippet name: | compress30BitUint - converts to 1 through 4 bytes, uses big-endian |
Eternal ID of this version: | #1029522/1 |
Text MD5: | 9b7189c50de8efdbf08a3e901d95c166 |
Transpilation MD5: | d6d8eb3b2001c7ee1806ad35165a4ef7 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-08-17 16:48:29 |
Source code size: | 500 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 289 / 379 |
Referenced in: | [show references] |