![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
long
Advanced tools
Package description
The 'long' npm package provides a comprehensive library for representing, converting, and performing arithmetic operations on 64-bit integers. This is particularly useful in environments like JavaScript, where the standard Number type can only safely represent integers up to 53 bits.
Creation of Long integers
This feature allows the creation of 64-bit integers. The constructor takes two arguments representing the low and high 32 bits of the integer, respectively.
const Long = require('long');
let longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
Arithmetic operations
This feature supports basic arithmetic operations such as addition, subtraction, multiplication, and division on 64-bit integers.
const Long = require('long');
let long1 = new Long(1, 0);
let long2 = new Long(1, 0);
let sum = long1.add(long2);
Comparison operations
This feature enables comparison operations like less than, greater than, equals, etc., between two Long instances.
const Long = require('long');
let long1 = new Long(1, 0);
let long2 = new Long(2, 0);
let isLessThan = long1.lessThan(long2);
The 'bignum' package also provides arbitrary precision arithmetic operations. Unlike 'long', which is limited to 64-bit, 'bignum' can handle much larger numbers, making it suitable for applications requiring high precision.
Similar to 'long', 'bigint' supports large integer operations. However, 'bigint' is built into modern JavaScript environments as a native type, offering better performance and integration with the language compared to 'long', which is a library.
Readme
A Long class for representing a 64-bit two's-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support.
As of the ECMAScript specification, number types have a maximum value of 2^53. Beyond that, JavaScript falls back to double internally. Furthermore, bitwise operations are always performed on 32bit numbers. However, in some use cases it is required to be able to perform reliable mathematical and/or bitwise operations on the full 64bits. This is where Long.js comes into play.
Long.js is based on the goog.math.Long class from the Closure Library. It uses two 32bit integers internally and provides methods for comparison, common tests, math and bitwise operations on the full 64bits. Additionally, some use cases also require to work with 64bit unsigned values, so Long.js has been extended with unsigned support while maintaining compatibility to the Closure Library implementation.
new Long(low, high[, unsigned=false])
and
Long.fromBits(low, high[, unsigned=false])
Long.fromInt(value[, unsigned=false])
including a cache for frequently used small numbersLong.fromNumber(value[, unsigned=false])
Long.fromString(value[, unsigned=false, radix=10])
Long#toInt()
Long#toNumber()
Long#toString([radix=10])
Long#getLowBits()
, Long#getHighBits()
and
Long#getLowBitsUnsigned()
, Long#getHighBitsUnsigned()
Long#equals(other)
, Long#notEquals(other)
, Long#lessThan(other)
, Long#lessThanOrEqual(other)
,
Long#greaterThan(other)
, Long#greaterThanOrEqual(other)
, Long#compare(other)
Long#isZero()
, Long#isNegative()
, Long#isOdd()
, Long#isEven()
Long#negate()
, Long#add(other)
, Long#subtract(other)
, Long#multiply(other)
, Long#div(other)
,
Long#modulo(other)
Long#not()
, Long#and(other)
, Long#or(other)
, Long#xor(other)
, Long#shiftLeft(numBits)
,
Long#shiftRight(numBits)
, Long#shiftRightUnsigned(numBits)
Long.toSigned()
, Long.toUnsigned()
Install: npm install long
var Long = require("Long");
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
console.log(longVal.toString());
...
require.config({
"paths": {
"Math/Long": "/path/to/Long.js"
}
});
require(["Math/Long"], function(Long) {
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
console.log(longVal.toString());
});
<script src="//raw.github.com/dcodeIO/Long.js/master/Long.min.js"></script>
var Long = dcodeIO.Long;
var longVal = new Long(0xFFFFFFFF, 0x7FFFFFFF);
alert(longVal.toString());
Apache License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.html
FAQs
A Long class for representing a 64-bit two's-complement integer value.
The npm package long receives a total of 21,323,300 weekly downloads. As such, long popularity was classified as popular.
We found that long demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.