Skip to main content

Current python 3's round function uses Banker's rounding, this package will help you to round off numbers the classical way.

Project description

PyClassicRound

The current implementation of round() function in Python 3 uses Banker's rounding i.e integers are rounded to the nearest even integer, this package allows you to round off numbers the classical way.

Installation

PyClassicRound has no dependencies.

> pip install PyClassicRound

Usage (example)

> from PyClassicRound import classic_round

> classic_round(2.55, 1) #outputs 2.6 whereas python 3's round() outputs 2.5

OR

> from PyClassicRound import classic_round as cround

> cround(2.55, 1) #outputs 2.6 whereas python 3's round() outputs 2.5

Parameters

  • Number that needs to be rounded off
  • Upto how many decimal places (optional) (defaults to 2 decimal points (Hundredths Place))

Input parameters can be in any format i.e. integer, float, string etc.

Output will be:

  • integer: if decimal point is 0
  • on successful operation: float
  • None: if the input value cannot be resolved / rounded off for ex. strings -> ("", " ", "abc")

License

MIT

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

PyClassicRound-2.2.tar.gz (1.8 kB view hashes)

Uploaded Source

Built Distribution

PyClassicRound-2.2-py3-none-any.whl (3.2 kB view hashes)

Uploaded Python 3

Supported by

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