
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
fixed-point
Advanced tools
Fixed point arithmetic with BigInt. Can be used for money or scientific calculations with known precision.
Fixed point arithmetic with BigInt. Minimalistic library that can be used for money or scientific calculations with known precision.
Install package npm install fixed-point
or include minified script on page.
import { FixedPoint } from 'fixed-point';
// Simple example: 0.3 - 0.2 = 0.1
console.log(new FixedPoint(0.3).sub(0.2).toString());
// Price with 30% discount, rounding benefiting the customer
FixedPoint.setRounding('floor');
console.log(new FixedPoint('99.95').mul(0.70).toFixed())
// Bitcoin fee with banker rounding: 1.0 BTC - 0.00005 BTC = 0.99995000 BTC
FixedPoint.setRounding('even');
FixedPoint.setPrecision(8);
console.log(new FixedPoint('1').sub('0.00005').toFixed() + ' BTC');
// Rounding mode for fast calculations
FixedPoint.setRounding('trunc');
FixedPoint.setPrecision(15);
console.log(new FixedPoint('3.14159265358979').mul('2'));
new FixedPoint(string)
- constructor from Stringnew FixedPoint(number)
- constructor from Numbera.toString()
- conversion to Stringa.toFixed()
- conversion to StringFixedPoint.setPrecision(number)
- set precision (2 decimal places is default)FixedPoint.setRounding(string)
- set rounding ('trunc'|'floor'|'ceil'|'even'), 'even' is defaulta.add(b)
- addition (exact)a.sub(b)
- subtraction (exact)a.mul(b)
- multiplication (rounded)a.div(b)
- division (rounded)a.eq(b)
- a == b
a.ne(b)
- a != b
a.gt(b)
- a > b
a.ge(b)
- a >= b
a.lt(b)
- a < b
a.le(b)
- a <= b
Status: alpha.
FAQs
Fixed point arithmetic with BigInt. Can be used for money or scientific calculations with known precision.
The npm package fixed-point receives a total of 2 weekly downloads. As such, fixed-point popularity was classified as not popular.
We found that fixed-point 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.