`setPrecision` is a small module providing a simple way to set the precision of a floating point number or decimal to the desired amount of significant digits.
Project description
setPrecision
About
setPrecision
is 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
setPrecision
usingpip
, enter the following:pip install setPrecision
-
You should now be able to import/run
setPrecision
within your python environment by entering the following:>>> from setPrecision import set ...
-
Done!
Manual Installation
Not recommended.
-
Before use, navigate to intended installation location, and create a new directory.
-
Install all dependencies for this package within said directory using:
pip install -r requirements.txt
-
Clone repository with the git client of your preference.
- (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.
- (Optional) move installation directory to
- Done!
Usage
-
In order to use
setPrecision
, start by importing the module to your Python environment:from setPrecision import set
-
Now, simply call the
set
method and enter your desired number to be formatted as thedigit
parameter, and the level of precision as theprecision
parameter:>>> myNumber = 3.141592653589793 # Not necessary to set number as variable. >>> myNumber = set(myNumber, 2) >>> print(myNumber) '3.15'
Note that the output is automatically rounded up when
digit >= 5
, and down whendigit < 5
.
- Both params can be entered in string format, and will output successfully assuming that both paramaters 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
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
Hashes for SetPrecision-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d2f939b8c33a1a3e62224f1e8515179f09760fdd966facaf785c0765fbb4d68 |
|
MD5 | 444af42d8d884911c94253ad8d1df1ac |
|
BLAKE2b-256 | 058519c5b866360954893448afdfdc00606a9a3f4833d44006e8a0e71523bdf0 |