Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
exactnumber
Advanced tools
Arbitrary-precision decimals. Enables making precise math calculations with rational numbers, without precision loss.
Arbitrary-precision decimals. Enables making precise math calculations with rational numbers, without precision loss.
console.log(1 + 0.36);
// returns 1.3599999999999999
console.log(ExactNumber(1).add('0.36').toString());
// returns 1.36
console.log(1 / 3);
// returns 0.3333333333333333
console.log(ExactNumber(1).div(3).toString());
// returns 0.(3)
console.log((1 / 49) * 49);
// returns 0.9999999999999999
console.log(ExactNumber(1).div(49).mul(49).toString());
// returns 1
console.log(10e16 + 5);
// returns 100000000000000000
console.log(ExactNumber('10e16').add(5).toString());
// returns 100000000000000005
2
and 16
NaN
, Infinity
or -0
.1.23(45)
and
, or
, xor
, shiftLeft
, shiftRight
)BigInt
type under the hood. It automatically switches back and forth between fixed-precision and fractional representations.npm i exactnumber
It can also be used directly from HTML (via jsDelivr):
<!-- loads the full, minified library into the global `exactnumber` variable -->
<script src="https://cdn.jsdelivr.net/npm/exactnumber"></script>
<!-- or loads the non-minified library -->
<script src="https://cdn.jsdelivr.net/npm/exactnumber/dist/index.umd.js"></script>
import { ExactNumber as N } from 'exactnumber';
N(1).add('3').toString(); // 4
N('1/7').add('1/10').toFraction(); // 17/70
N('1/7').toString(); // 0.(142857)
N('1/7').toFixed(3); // 0.142
N('1/7').trunc(3).toString(); // 0.142
N('0.(3)').add('0.(6)').toString(); // 1
N('0b1100').bitwiseAnd('0b1010').toString(2); // 1000
N.max('1/1', '10/2', 3).toString(); // 5
N.fromBase('123', 4).toString(); // 27
import { PI, sin } from 'exactnumber';
PI(10); // 3.1415926535
const PI_OVER_2 = N(PI(10)).div(2);
sin(PI_OVER_2, 5); // 1.00000
sqrt()
, cbrt()
, nthroot()
pow()
, exp()
log()
, logn()
, log10()
, log2()
,PI()
, sin()
, cos()
, tan()
asin()
, acos()
, atan()
sinh()
, cosh()
License: MIT
Copyright © 2022 Dani Biró
FAQs
Arbitrary-precision decimals. Enables making math calculations with rational numbers, without precision loss.
The npm package exactnumber receives a total of 2,352 weekly downloads. As such, exactnumber popularity was classified as popular.
We found that exactnumber demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.