How to use the fromBits function from long

Find comprehensive JavaScript long.fromBits code examples handpicked from public code repositorys.

7
8
9
10
11
12
13
14
15
16
// Demonstrating the use together with Long.js (https://github.com/dcodeIO/Long.js)
//
// Packing a long requires the input of a 2 part array containing the [low, high] bits
// of the specific long value.
// Unpacking a long results in a 3 part array containing [low, high, unsigned] bits and flag.
// The decoded value can be applied directly to Long.fromBits()
//
// Test number u            228290380562207 (BE: 0x00, 0x00, 0xcf, 0xa0, 0xff, 0x09, 0xff, 0x1f)
//                                          (LE: 0x1f, 0xff, 0x09, 0xff, 0xa0, 0xcf, 0x00, 0x00)
// Test number s           -228290380562207 (BE: 0xff, 0xff, 0x30, 0x5f, 0x00, 0xf6, 0x00, 0xe1)
fork icon2
star icon0
watch icon0

+ 11 other calls in file

6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
 * @expose
 */
Long.from28Bits = function(part0, part1, part2, unsigned) {
    // 00000000000000000000000000001111 11111111111111111111111122222222 2222222222222
    // LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
    return Long.fromBits(part0 | (part1 << 28), (part1 >>> 4) | (part2) << 24, unsigned);
};

/**
 * Returns a Long representation of the given string, written using the given
fork icon0
star icon0
watch icon1

+ 181 other calls in file