Round half away from zero.
pip install round2
Since python's default round function uses 'bankers rounding', I made this small module that uses 'commercial rounding' instead. This means half is rounded up for positive numbers and down for negative numbers:
>>> from round2 import round2
>>> round2(1.5)
2
>>> round2(2.5)
3
>>> round2(-1.5)
-2
>>> round2(-2.5)
-3
>>> round2(2.5, decimals=1)
2.5
If decimals=0 (default), returns an int, otherwise a float, just like Python’s round function.
Implemented in Cython with type hinting in Python.
Metadata
Release files for round2 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| round2-0.0.4.tar.gz | 24.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| round2-0.0.4-cp39-cp39-win_amd64.whl | CPython 3.9 | CPython 3.9 | Windows x86-64 | Details |
Total release size: 38.4 kB
Release files / round2-0.0.4.tar.gz
| Download URL | round2-0.0.4.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b5f43861ad31db9a2a26dfb50b8591ea5524984e6f58fc59c2a4e5c7dde9a2a
|
|
BLAKE2b-256 checksum How to use checksums |
786d383882b83f3224168c69dc54981d83ac78db17548bd197c639a4969d23a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / round2-0.0.4-cp39-cp39-win_amd64.whl
| Download URL | round2-0.0.4-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 14.4 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f509c5fc5a7355c2ec6906b9babc6ae9fcc240fb6a25e162c73090e3146a0c6e
|
|
BLAKE2b-256 checksum How to use checksums |
d03348af2bd0ed8dc9d90256a2fbe2b5aa042e6ade8ebfc7fb015c376a0018e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|