
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@bondvet/decimal
Advanced tools
Simple decimal arithmetic for the browser and node.js!
Why don’t my numbers, like 0.1 + 0.2 add up to a nice round 0.3,
and instead I get a weird result like 0.30000000000000004?
Because internally, computers use a format (binary floating-point)
that cannot accurately represent a number like 0.1, 0.2 or 0.3 at all.
Source : http://floating-point-gui.de/
I wrote this because I needed to do simple computation in the browser and I couldn't find a lightweight library to do it.
<script src="lib/decimal.js"></script>
npm install decimal
then in your program
var Decimal = require('decimal');
>>> 1.1 + 2.2
3.3000000000000003
>>> Decimal('1.1').add('2.2').toNumber()
3.3
>>> 4.01 * 2.01
8.060099999999998
>>> Decimal('4.01').mul('2.01').toNumber()
8.0601
>>> Decimal.mul('4.01', '2.01').toNumber()
8.0601
Of course you can, I suck at math, and this implementation is very naive. If you are a math Guru and you see something wrong or a way to simplify things you can send in a pull request.
Create a new Decimal from n. n can be a string, integer, or
another Decimal.
Returns the Decimal instance as a string.
Turn a Decimal into a Number.
Return a new Decimal containing the instance value plus n.
Return a new Decimal containing the instance value minus n.
Return a new Decimal containing the instance value multiplied by n.
Return a new Decimal containing the instance value integrally divided by n.
FAQs
Simple decimal arithmetic for the browser and node.js!
We found that @bondvet/decimal 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.