How to use the fromNumber function from long
Find comprehensive JavaScript long.fromNumber code examples handpicked from public code repositorys.
13 14 15 16 17 18 19 20 21 22 23 24 25
var Bytes = require('./util/bytes'); var CONST = {}; CONST.PROTOCOL = 'org.apache.hadoop.hbase.ipc.HRegionInterface'; CONST.CLIENT_VERSION = Long.fromNumber(29); /** * Timestamp to use when we want to refer to the latest cell. * This is the timestamp sent by clients when no timestamp is specified on
93
281
0
52 53 54 55 56 57 58 59 60 61
beforeEach(function beforeEach() { round = 0; protocolVersion = Long.fromInt(1); proposedAppVersion = Long.fromInt(1); blockHeight = Long.fromNumber(1); time = millisToProtoTimestamp(Date.now()); timeMs = protoTimestampToMillis(time); epochInfo = { currentEpochIndex: 1,
22
32
13
36 37 38 39 40 41 42 43 44 45
plainObject = getBlockExecutionContextObjectFixture(dataContract); lastCommitInfo = CommitInfo.fromObject(plainObject.lastCommitInfo); logger = plainObject.contextLogger; height = Long.fromNumber(plainObject.height); proposedAppVersion = Long.fromNumber(plainObject.proposedAppVersion); coreChainLockedHeight = plainObject.coreChainLockedHeight; version = Consensus.fromObject(plainObject.version); epochInfo = plainObject.epochInfo;
22
32
13
GitHub: nlf/protobuf.js
107 108 109 110 111 112 113 114 115
expect(check.int64).to.exist; expect(check.int64).to.deep.equal(decoded); }); it('Can encode a uint64', function () { decoded = long.fromNumber(987654321, true); encoded = client.encode('Test1', { uint64: decoded }); expect(encoded).to.be.an.instanceof(Buffer); });
9
24
0
+ 23 other calls in file
256 257 258 259 260 261 262 263 264 265
MutableBigInteger.prototype.mulsub = function (q, a, x, len, offset) { var xLong = Long.fromNumber(x >>> 32); var carry = Long.fromNumber(0); offset += len; for (var j = len - 1; j >= 0; j--) { var product = Long.fromNumber(a[j] >>> 32).multiply(xLong).add(carry); var difference = Long.fromNumber(q[offset]).subtract(product); q[offset--] = difference.low; carry = product.shiftRightUnsigned(32).add( Long.fromNumber(difference.low >>>32).compare(Long.fromNumber(~product.low >>> 32)) > 0 ? Long.fromInt(1) : Long.fromInt(0)
4
9
13
+ 239 other calls in file
307 308 309 310 311 312 313 314 315 316
var len = x.length; var product = Long.ZERO; var carry = 0; for (var i = len-1; i >= 0; i--) { product = ylong.multiply( Long.fromNumber(x[i] >>> 32) ).add(Long.fromInt(carry)); x[i] = product.low; carry = product.high; } // Perform the addition
4
9
13
+ 84 other calls in file
53 54 55 56 57 58 59 60 61 62
it('Algorithm validation', function (done) { var nChunk,dhLong,qhat,qrem; nChunk = 5982811586; dhLong = 3725290298; qhat = Long.fromNumber(nChunk).div(Long.fromNumber(dhLong)).low; qhat.should.eql(1); qrem = Long.fromNumber(nChunk).subtract(Long.fromInt(qhat).multiply(Long.fromNumber(dhLong))).low; qrem.should.eql(-2037446008);
4
9
0
+ 8 other calls in file
41 42 43 44 45 46 47 48 49
res.toNumber().should.be.eql(228290380562207); }); it('pack <q', function() { //var num = new Long(0x00f600e1, 0xffff305f, true); var num = Long.fromNumber(-228290380562207); // signed // Pass long representation to jspack var buf = jspack.Pack('<q', [[num.getLowBitsUnsigned(), num.getHighBitsUnsigned()]]);
2
0
0
+ 15 other calls in file
180 181 182 183 184 185 186 187 188 189
function GenerateMostSigBytes(UnixTime) { let finalval = long.fromNumber(UnixTime).multiply(10000).multiply(long.fromNumber(122192928000000000)); let a = finalval.and(long.fromNumber(-281474976710656)).shiftRightUnsigned(48); let b = finalval.shiftLeft(32); let c = long.fromNumber(281470681743360).and(finalval).shiftRightUnsigned(16); return a.or(b).or(4096).or(c).toString() } function GenerateLeastSigBytes() {
1
9
1
+ 3 other calls in file
GitHub: Fslink32/pmrv2
76 77 78 79 80 81 82 83 84 85 86 87
}; },{"./read":8,"./util":12,"lie":38}],3:[function(require,module,exports){ 'use strict'; var Long = require('long'); var l127 = Long.fromNumber(127, true); function makeLong(n) { return Long.fromNumber(n, true); }
0
0
1
+ 168 other calls in file
205 206 207 208 209 210 211 212 213 214
if (!(options.before instanceof Date)) options.before = new Date(options.before); options.maxID = long.fromNumber(options.before.getTime() - 14200704e5).shiftLeft(22).toString(); } if (options.after) { if (!(options.after instanceof Date)) options.after = new Date(options.after); options.minID = long.fromNumber(options.after.getTime() - 14200704e5).shiftLeft(22).toString(); } if (options.during) { if (!(options.during instanceof Date)) options.during = new Date(options.during); const t = options.during.getTime() - 14200704e5;
0
0
1
+ 23 other calls in file
11 12 13 14 15 16 17 18 19 20
} else { return ++helper.unique_nonce_entropy % 256; } })()); var long = Long.fromNumber(Date.now()); // console.log('unique_nonce_uint64 date\t',ByteBuffer.allocate(8).writeUint64(long).toHex(0)) // console.log('unique_nonce_uint64 entropy\t',ByteBuffer.allocate(8).writeUint64(Long.fromNumber(entropy)).toHex(0)) long = long.shiftLeft(8).or(Long.fromNumber(entropy)); // console.log('unique_nonce_uint64 shift8\t',ByteBuffer.allocate(8).writeUint64(long).toHex(0))
0
0
1
long.default is the most popular function in long (905 examples)