Skip to main content

The package contains mathematical rounding function

Project description

Mathematical rounding in Python

This package has one purpose: fast mathematical rounding of numbers.

Installation

Use the following command to install the package:

pip install math-rounding

The package can use numba to increase speed of the calculations. If you want to install it with numba, you can use the following command:

pip install math-rounding[numba]

or just install numba separately.

Usage

The main function of the package math_rounding has the following signature:

def math_rounding(n: Number, p: int = 0) -> float:
    ...

where:

  • n is the number to round;
  • p is integer number that specifies the position to which rounding will be performed.

p could be a positive number or a negative number. It represents the position in the number from the dot:

  • when it's equal to 0 (default), the rounding will be performed to integer;
  • when it's positive, it represents the position in fractional part of the number;
  • when it's negative, it represents the position in integer part of the number.

Example

from math_rounding import math_rounding

print(math_rounding(0.5))      # 1.0
print(math_rounding(-0.5))     # -1.0
print(math_rounding(1.1))      # 1.0
print(math_rounding(0.05, 1))  # 0.1
print(math_rounding(5, -1))    # 10.0
print(math_rounding(15, -1))   # 20.0

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

math_rounding-1.0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

math_rounding-1.0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file math_rounding-1.0.1.tar.gz.

File metadata

  • Download URL: math_rounding-1.0.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for math_rounding-1.0.1.tar.gz
Algorithm Hash digest
SHA256 776d2170460f8b1347d8ec5ddf5bec46b4a1da55e87b20659cd18d161f9cb07c
MD5 3b1dbb4bad42346cc6a4fecc722c5346
BLAKE2b-256 2491544628f04f9f2524d883fac40276416c531596b83e7359c3ac165b89c2fa

See more details on using hashes here.

File details

Details for the file math_rounding-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: math_rounding-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.11

File hashes

Hashes for math_rounding-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f3f65d461323231edc64c93ebffff6aded65bc26fe180c5b6ad1aaea84749901
MD5 f791584039131c9d504ba697a3499844
BLAKE2b-256 5f37aaf635e7f6bb1da57a425efc5e86d97f6d9ed83765173cfb343621a38a74

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