Lodash _.round() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Math

Definition

Computes number rounded to precision (nearest value). Part of Lodash 4.x Math (since 3.10.0).

Note: Half values follow Math.round (toward +Infinity). Not banker's / half-to-even rounding.

Syntax

Call _.round. Start with this line.

Lodash
_.round(number, [precision=0])
CallWhat it does
_.round(number, [precision=0])Primary signature.

Prefer import round from "lodash/round" when you want a smaller bundle.

Library declarations
Lodash
_.round(number, [precision=0])

Parameters

ParameterDescription
numberRequired. Value to round (coerced with toNumber)
precisionOptional. Places to round to; default 0; capped at 292

Return Value

Return ValueDescription
*Nearest number (or NaN if input is not numeric)

Lodash Examples

Example 1 — Official: Whole Number

Default precision 0 rounds to the nearest integer.

Lodash
_.round(4.006);
// → 4
Try It Yourself

How It Works

  1. Input. Official sample: 4.006.
  2. Nearest. Closer to 4 than to 5.
  3. Result. Returns 4.
  4. Default. Omitting precision means precision 0.

Example 2 — Official: Two Decimal Places

Positive precision keeps that many digits after the point.

Lodash
_.round(4.006, 2);
// → 4.01
Try It Yourself

How It Works

  1. Precision 2. Look at the hundredths place.
  2. Next digit. The thousandths digit is 6 → round up.
  3. Result. 4.01.
  4. Use. Common for money display (still use money libraries for currency).

Example 3 — Official: Negative Precision

Negative precision rounds to tens, hundreds, and so on.

Lodash
_.round(4060, -2);
// → 4100
Try It Yourself

How It Works

  1. −2. Target the hundreds place.
  2. 4060. Closer to 4100 than to 4000.
  3. Result. Returns 4100.
  4. Pattern. -1 → tens, -3 → thousands.

Example 4 — Safer Than Multiply / Divide

Lodash avoids a common floating-point trap with decimal rounding.

Lodash
_.round(1.005, 2);
// → 1.01

Math.round(1.005 * 100) / 100;
// → 1     // classic FP pitfall
Try It Yourself

How It Works

  1. Naive. 1.005 * 100 is not stored as exactly 100.5.
  2. Math.round. Can therefore return 1 after dividing back.
  3. _.round. Uses a safer shift → 1.01.
  4. Takeaway. Prefer _.round for decimal places in JS.

Example 5 — round vs ceil vs floor

Same input, three different directions.

Lodash
_.round(4.006);  // → 4
_.ceil(4.006);   // → 5
_.floor(4.006);  // → 4
Try It Yourself

How It Works

  1. round. Nearest → 4.
  2. ceil. Always up → 5.
  3. floor. Always down → 4.
  4. Pick. Choose by the policy your feature needs.

Browser & Runtime Support

_.round is a Lodash 4.x Math helper (since 3.10.0). It builds on native Math.round plus Lodash number coercion. It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash.

✓ Stable · Lodash 3.10.0+

_.round()

Available in [email protected] full builds and the lodash/round modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.

100% With Lodash 3.10+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.round Lodash 3.10.0+

Bottom line: Safe for production once Lodash is loaded. Prefer import round from "lodash/round" for smaller bundles. Use it whenever you need nearest-value rounding with precision.

Frequently Asked Questions

_.round(number, [precision=0]) rounds number to the nearest value at the given precision. With precision 0 it behaves like Math.round for finite numbers.
Positive precision keeps that many decimal places. Negative precision rounds to tens (−1), hundreds (−2), and so on — e.g. _.round(4060, -2) → 4100.
round goes to the nearest value. ceil rounds toward +Infinity. floor rounds toward −Infinity.
Like Math.round: toward +Infinity. So _.round(0.5) → 1 and _.round(-0.5) → -0. This is not banker's (half-to-even) rounding.
The multiply/divide pattern can lose precision (e.g. 1.005). Lodash uses an exponential-shift approach so _.round(1.005, 2) → 1.01.
Use import round from "lodash/round" or require("lodash/round") for tree-shaking. Full build: import _ from "lodash" then _.round.

Next: _.subtract()

Subtract one number from another with Lodash.

_.subtract() tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful