Round half away from zero.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file round2-0.0.4.tar.gz.
File metadata
- Download URL: round2-0.0.4.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b5f43861ad31db9a2a26dfb50b8591ea5524984e6f58fc59c2a4e5c7dde9a2a
|
|
| MD5 |
3c31d778f2f024dc1c3e1afcc4296e5f
|
|
| BLAKE2b-256 |
786d383882b83f3224168c69dc54981d83ac78db17548bd197c639a4969d23a3
|
File details
Details for the file round2-0.0.4-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: round2-0.0.4-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 14.4 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f509c5fc5a7355c2ec6906b9babc6ae9fcc240fb6a25e162c73090e3146a0c6e
|
|
| MD5 |
5f56b73b81f9b8caa0aa881cc8d1dc41
|
|
| BLAKE2b-256 |
d03348af2bd0ed8dc9d90256a2fbe2b5aa042e6ade8ebfc7fb015c376a0018e7
|