How to use the fromInt function from long
Find comprehensive JavaScript long.fromInt code examples handpicked from public code repositorys.
long.fromInt is a function in the Long.js library that converts a JavaScript number to a 64-bit long integer.
46 47 48 49 50 51 52 53 54 55
createValidatorSetUpdateMock, ); }); it('should rotate validator set and return ValidatorSetUpdate if height is divisible by ROTATION_BLOCK_INTERVAL', async () => { height = Long.fromInt(15); const quorumHash = Buffer.alloc(64).fill(1).toString('hex'); validatorSetMock.rotate.resolves(true);
22
32
13
+ 31 other calls in file
22 23 24 25 26 27 28 29 30 31
beforeEach(function beforeEach() { round = 42; loggerMock = new LoggerMock(this.sinon); height = Long.fromInt(15); version = { app: Long.fromInt(1), }; proposalBlockExecutionContextMock = new BlockExecutionContextMock(this.sinon); proposalBlockExecutionContextMock.getVersion.returns(version);
22
32
13
+ 29 other calls in file
How does long.fromInt work?
long.fromInt()
is a function provided by the long
library that creates a Long
instance from a 32-bit integer value.
It takes an integer value as input and returns a new Long
object with the same numeric value. If the input value is larger than 32 bits, the high bits are truncated.
50 51 52 53 54 55 56 57 58 59
let simplifyMasternodeListMock; let validMasternodesListLength; beforeEach(function beforeEach() { round = 0; protocolVersion = Long.fromInt(1); proposedAppVersion = Long.fromInt(1); blockHeight = Long.fromNumber(1); time = millisToProtoTimestamp(Date.now()); timeMs = protoTimestampToMillis(time);
22
32
13
+ 3 other calls in file
1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868
for (var i=0; i<numInts; i++) mag[i] = this.mag[i + (this.mag.length - numInts)]; // Mask out any excess bits var excessBits = (numInts << 5) - p; mag[0] &= Long.fromInt(1).shiftLeft(32-excessBits).low - 1; return (mag[0]==0 ? _fromMag(1, mag) : BigInteger.fromMag(mag, 1)); }
4
9
13
+ 4 other calls in file
Ai Example
1 2 3 4
const Long = require("long"); const num = Long.fromInt(42); console.log(num.toString()); // Output: 42
In this example, we first import the Long module and then create a new Long object with the value of 42 using the fromInt() method. Finally, we log the value of this Long object using the toString() method.
212 213 214 215 216 217 218 219 220 221
* divisor a back to the dividend result at a specified offset. It is used * when qhat was estimated too large, and must be adjusted. * int[] a, int[] result, int offset */ MutableBigInteger.prototype.divadd = function (a, result, offset) { var carry = Long.fromInt(0); for (var j = a.length-1; j >= 0; j--) { var sum = Long.fromNumber(a[j] >>> 32).add(Long.fromNumber(result[j + offset] >>> 32)).add(carry); result[j+offset] = sum.low; carry = sum.shiftRightUnsigned(32);
4
9
13
+ 59 other calls in file
92 93 94 95 96 97 98 99 100
var dh = -569676998; var dhLong = dh >>> 32; dhLong.should.eql(3725290298); // var nChunk = (1 << 32) | (1687844290 >>> 32); var a = Long.fromInt(1).shiftLeft(32); var b = Long.fromInt(1687844290); var nChunk = a.or(b).toNumber(); nChunk.should.eql(5982811586);
4
9
0
+ 2 other calls in file
GitHub: Fslink32/pmrv2
6520 6521 6522 6523 6524 6525 6526 6527 6528 6529
var TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2; /** * @type {!Long} */ var TWO_PWR_24 = Long.fromInt(1 << 24); /** * @type {!Long} * @expose
0
0
1
+ 12 other calls in file
535 536 537 538 539 540 541 542 543 544
endorsements: ['failed-endorsements'] }); const results = await discoveryHandler._endorse({}, {}, 'proposal'); results[0].endorsements[0].should.equal('failed-endorsements'); const m = new Map(); sinon.assert.calledWith(discoveryHandler._modify_groups, m, m, m, m, m, m, Long.fromInt(1), 'ledgerHeight', {endorsements: {}, layouts: [{}]}); }); }); describe('#_endorse_layout', () => {
0
0
1
228 229 230 231 232 233 234 235 236 237
const ignored = this._create_map(request.ignored, 'endpoint'); const required_orgs = this._create_map(request.requiredOrgs, 'mspid'); const preferred_orgs = this._create_map(request.preferredOrgs, 'mspid'); const ignored_orgs = this._create_map(request.ignoredOrgs, 'mspid'); let preferred_height_gap = Long.fromInt(1); // default of one block try { if (Number.isInteger(request.preferredHeightGap) || request.preferredHeightGap) { preferred_height_gap = convertToLong(request.preferredHeightGap, true); }
0
0
1
long.default is the most popular function in long (905 examples)