SetPrecision
About
SetPrecisionis a small module providing a simple way to set the precision of a floating point number or decimal to the desired amount of digits following the decimal point.
Installation
Using PIP (Recommended)
Easiest method. Highly recommended over manual installation.
-
To install
SetPrecisionusingpip, enter the following:python -m pip install SetPrecision
-
Done!
Manual Installation
Not recommended.
-
Before use, navigate to intended installation location, and create a new directory.
-
Clone repository with the git client of your preference using the following command:
-
git clone https://github.com/schlopp96/SetPrecision/releases/latest
-
-
Install all dependencies for this package within said directory using:
-
pip install -r requirements.txt
-
-
(Optional): move installation directory to
"path/to/Python/Libs/site_packages"to be able to import this package to a Python program like any other importable package. -
Done!
Usage
-
In order to use
SetPrecision, start by importing the module to your Python environment:from SetPrecision import set_precision
-
Now, simply call the
set_precisionmethod and enter your desired number to be formatted as thenumberparameter, and the level of precision as theprecisionparameter:>>> testA = 3.141592653589793 # Not necessary to set number as variable. >>> testA = set_precision(testA, 2) >>> print(testA) '3.15' >>> testB = 3.141592653589793 >>> testB = set_precision(testB, 4) >>> print(testB) '3.1416'
Note that the output is automatically rounded up when
number >= 5, and down whennumber < 5.
- Both params can be entered in string format, and will output successfully assuming that both parameters can be cast to their appropriate types.
- This is done automatically.
Contact the Author
- If you have any questions, comments, or concerns that cannot be alleviated through the project's GitHub repository, please feel free to contact me through my email address:
schloppdaddy@gmail.com
Metadata
Release files for SetPrecision 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| SetPrecision-0.2.0.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| SetPrecision-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.4 kB
Release files / SetPrecision-0.2.0.tar.gz
| Download URL | SetPrecision-0.2.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12c2350bd112f5845a38cf369bdb03b04fb3d2ed631f3320005208b94806f415
|
|
BLAKE2b-256 checksum How to use checksums |
fb3cec3bb7543edc82c1266c79b9b8e34b6cbb619e0450a10a2ba11e680901f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / SetPrecision-0.2.0-py3-none-any.whl
| Download URL | SetPrecision-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
269977b31328ff8a46d5b0a79116d40aaca7afe49ae31b0f73eaf98b0a2b053f
|
|
BLAKE2b-256 checksum How to use checksums |
089dd9e2dc8bfc8644ed8bcfb5dded4fdd1efd37dc18a82b75193555bc67632c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|