Skip to main content

No project description provided

Project description

betterRound - A simple, small Python package for better rounding.

![version: 1.0](https://img.shields.io/badge/main_version-1.0-red)
![python version: 3.14 - 3.16](https://img.shields.io/badge/python_version-3.14_--_3.16-%233776AB?logo=python&logoColor=%23FFFFFF)

Be honest, the current round() function _sucks_. Only rounding to units? That's why I have created betterRound. Here's how it works.

Setup

Make sure that betterRound is installed (run `pip install betterRound` in your terminal), then add `from betterRound import *`. Now you can use betterRound in your project!

Usage

betterRound only includes one function - `betterRound()`. `betterRound()` takes 3 inputs, `betterRound(num, sf = 1, opt = "round")`. Num is the number to round. Any number should work. Negatives are kinda wierd as I just thought of it now and put in a quick fix, it should be fully fixed later. Sf stands for Significant Figure, and by default is 1, which means the first digit will be the only one that stays the same. For decimals, you dont need to increment your sf, as my code will do it for you, so if you wanted to round everything after the 4 in 329.**4**826, you would put 4, as it is the fourth number. Finally, opt is the option argument. It is converted into lowercase before used, so don't worry about that. There are 3 options;

  1. Up/Ceiling - Always round up.
  2. Down/Floor - Always round down.
  3. Round/Anything else - If the number after the last sf is over 5, round up, otherwise round down.

Examples

print(betterRound(928346, 4))
>> 928300

print(betterRound(111111, 1, up))
>> 200000

Other Info

Numbers like 00000 that become 0 as a python integer won't work, even if opt="up", as there wont be enough digits.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

betterround-1.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

betterround-1.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file betterround-1.1.tar.gz.

File metadata

  • Download URL: betterround-1.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for betterround-1.1.tar.gz
Algorithm Hash digest
SHA256 ca09cced8c7133e7c0ecefa89f5a79af6584146b3c1bf375212cf093d319654f
MD5 bc7900abb9f947a7c3f53418b1b71445
BLAKE2b-256 dae733be3ec30b5cd593b2949e3e5365d64d6c12680594c1ca05993fa798bb1e

See more details on using hashes here.

File details

Details for the file betterround-1.1-py3-none-any.whl.

File metadata

  • Download URL: betterround-1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for betterround-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e22238603ab40d06f0f59817fd92bec52436b043dcca4207becc95f52a2ca44
MD5 a69894ed1471de9ebaa22c9ddc32ca77
BLAKE2b-256 6905acd1f96e74a872b4dc05c5e7a9e389b5e2560925939b38cd976265a731a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page