
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
more-rounding
Advanced tools
A library that offers more number rounding options for JavaScript and TypeScript
A library that offers more number rounding options for JavaScript and TypeScript
npm install more-rounding --save
<script src="https://joker876.github.io/more-rounding/dist/index.min.js"></script>
More Rounding exports a single object, containing all provided functions.
import * as MoreRounding from 'more-rounding';
MoreRounding.round(number: number): numberRounds a number towards the nearest integer. Equivalent to Math.round()
number - the number to be rounded.MoreRounding.round(2.3) // 2
MoreRounding.round(-2.3) // -2
MoreRounding.round(2.5) // 3
MoreRounding.round(-2.5) // -2
MoreRounding.roundUp(number: number): numberRounds a number towards the next integer (towards Infinity). Equivalent to Math.ceil()
number - the number to be rounded.MoreRounding.roundUp(2.3) // 3
MoreRounding.roundUp(-2.3) // -2
MoreRounding.roundUp(2.5) // 3
MoreRounding.roundUp(-2.5) // -2
MoreRounding.roundDown(number: number): numberRounds a number towards the previous integer (towards negative Infinity). Equivalent to Math.floor()
number - the number to be rounded.MoreRounding.roundDown(2.3) // 2
MoreRounding.roundDown(-2.3) // -3
MoreRounding.roundDown(2.5) // 2
MoreRounding.roundDown(-2.5) // -3
MoreRounding.toZero(number: number): numberRounds a number towards the next integer (towards the number 0).
For negative numbers, it is equivalent to Math.ceil(). For positive, equivalent to Math.floor().
number - the number to be rounded.MoreRounding.toZero(2.3) // 2
MoreRounding.toZero(-2.3) // -2
MoreRounding.toZero(2.5) // 2
MoreRounding.toZero(-2.5) // -2
MoreRounding.fromZero(number: number): numberRounds a number towards the next integer (away from the number 0).
For negative numbers, it is equivalent to Math.floor(). For positive, equivalent to Math.ceil().
number - the number to be rounded.MoreRounding.fromZero(2.3) // 3
MoreRounding.fromZero(-2.3) // -3
MoreRounding.fromZero(2.5) // 3
MoreRounding.fromZero(-2.5) // -3
MoreRounding.toPrecision(number: number, precision?: number, mode?: string): numberRounds a number to a certain precision.
number - the number to be rounded.precision - the amount of decimal places to be rounded to. Positive numbers mean more decimal places, negative numbers will round to subsequent powers of 10. Optional, default 1.mode - the basic rounding function to use. Optional, default "normal". Available rounding modes are:
normal - uses MoreRounding.roundup - uses MoreRounding.roundUpdown - uses MoreRounding.roundDownto_zero - uses MoreRounding.toZerofrom_zero - uses MoreRounding.fromZeroMoreRounding.toPrecision(2.3725) // 2.4
MoreRounding.toPrecision(2.3725, 3) // 2.373
MoreRounding.toPrecision(2.5131, 3, 'up') // 2.524
MoreRounding.toPrecision(253.5, -2) // 300
MoreRounding.toMultiple(number: number, multiple?: number, mode?: string): numberRounds a number to the nearest multiple of a number.
number - the number to be rounded.multiple - the multiple to round to. Optional, default 1.mode - the basic rounding function to use. Optional, default "normal". Available rounding modes are:
normal - uses MoreRounding.roundup - uses MoreRounding.roundUpdown - uses MoreRounding.roundDownto_zero - uses MoreRounding.toZerofrom_zero - uses MoreRounding.fromZeroMoreRounding.toMultiple(2.3725) // 2
MoreRounding.toMultiple(2.3725, 4) // 4
MoreRounding.toMultiple(12, 5) // 10
MoreRounding.toMultiple(13, 5) // 15
MoreRounding.toMultiple(13, 5, 'down') // 10
MoreRounding.toMultiple(5123, 77) // 5159
MoreRounding.approximate(number: number, multiple?: number, mode?: string, locale?: string): stringRounds a number to a certain long number (subsequent powers of 1,000), to a certain precision.
number - the number to be rounded.precision - the amount of decimal places to be rounded to, on top of the approximation. Positive numbers mean more decimal places, negative numbers will round to subsequent powers of 10. Optional, default 1.unit - the unit to round to. Accepts any unit from the table found below. Leaving it undefined will approximate it to the highest unit, where the approximation is in this range: 1,000 > x ≥ 1.locale - if specified, the number will be formatted according to this locale. Uses Number.prototype.toLocaleString().unitMap - an object used for mapping default units to custom strings. If not specified or there is no mapping for the approximation unit, the default unit string will be used.MoreRounding.approximate(1247) // 1.2k
MoreRounding.approximate(351334) // 351.3k
MoreRounding.approximate(1354348, 2) // 1.35M
MoreRounding.approximate(7346834138, 0, 'M') // 7347M
MoreRounding.approximate(7346834138, 2, 'M', 'en-US') // 7,346.83M
| Unit | Equivalent number |
|---|---|
k | 1,000 |
M | 1,000,000 |
B | 10^9 |
T | 10^12 |
Qa | 10^15 |
Qi | 10^18 |
Sx | 10^21 |
Sp | 10^24 |
Oc | 10^27 |
No | 10^30 |
Dc | 10^33 |
FAQs
A library that offers more number rounding options for JavaScript and TypeScript
The npm package more-rounding receives a total of 300 weekly downloads. As such, more-rounding popularity was classified as not popular.
We found that more-rounding 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 for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.