skillfed

rounders

round-function equivalents with different rounding-modes

rounders v0.2.0 149.0K downloads/30d#11,011 on PyPI5
Permissive license Active released

What it is and what it does

Rounders extends Python's built-in `round` function to support thirteen different rounding modes beyond the default Banker's rounding (TIES_TO_EVEN). It provides both mode-specific functions (like `round_ties_to_away` or `ceil`) and a general `round` function that accepts a `mode` parameter. The package also adds `round_to_figures` for rounding to significant figures rather than decimal places, which is useful in scientific and financial contexts where relative precision matters more than absolute decimal precision.

The package supports rounding Decimal, Fraction, and float types. It includes six to-nearest modes (handling ties differently), six directed modes (always rounding in one direction), and one specialized mode for avoiding double-rounding errors. Common use cases include matching JavaScript's `Math.round` behavior, implementing school-taught rounding (ties away from zero), or selecting IEEE 754 compliant rounding for numerical computing.

Use it for:

  • Financial calculations where you need to round ties away from zero instead of to even, matching common business expectations.
  • Scientific data processing where rounding to significant figures is more meaningful than rounding to a fixed decimal place.
  • Porting code from JavaScript or other languages that use different default rounding modes.
  • Numerical algorithms that require specific rounding modes to avoid double-rounding errors (TO_ODD mode).
  • Educational or testing scenarios where you need to demonstrate or verify different rounding behaviors.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides drop-in replacements for Python's built-in `round` function with thirteen different rounding modes, plus functions for rounding to significant figures instead of decimal places.

Yes. The package has zero dependencies, low install friction, active maintenance, permissive licensing, and fills a genuine gap in Python's standard library. It's useful for anyone working with financial data, scientific calculations, or code that must match specific rounding semantics. No known vulnerabilities.

Install

rounders on PyPI

pip

pip install rounders

uv

uv add rounders

poetry

poetry add rounders

Installing rounders

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of June 2024, though infrequently updated (last commit 796 days ago). Repository is not archived.

License in practice

Licensed under Apache 2.0 (permissive). You can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.

Quickstart

from rounders import round, TIES_TO_AWAY

# Default Banker's rounding
result = round(2.5)

# Round ties away from zero
result = round(2.5, mode=TIES_TO_AWAY)

# Round to significant figures
from rounders import round_to_figures
result = round_to_figures(1.234567, 3)

Requires Python 3.8 or later.

Verify before relying

  • Whether the package has a published test suite or documented test coverage.
  • Performance characteristics when rounding very large numbers or high-precision decimals.

Package facts

License not declared (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 796 days since the last release
Last repo commit
First released
Downloads 148,951/month — #11,011 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: rounders-0.2.0-py3-none-any.whl

Keywords: round, rounding, significant figures, decimal places, rounding mode

License :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Mathematics

Tags

rounding modessignificant figures roundingbanker's rounding alternativedecimal rounding controlround away from zerocustom rounding functionsties to even rounding
numeric-precisionrounding-modes

More Mathematics packages