Large numbers with high precision
Project description
Vinculum
Vinculum is a Python package for handling large numbers with high precision.
Examples
Numbers are recorded as fractions rather than floating-point decimals, so 1.2 - 1.0
really does equal 0.2
.
Using native float
:
a = 1.2
b = 1.0
c = a - b
print(c) # 0.19999999999999996
Using Vinculum Fraction
:
from vinculum import Fraction
a = Fraction.from_float(1.2)
b = Fraction.from_float(1.0)
c = a - b
print(c) # 1/5
print(c.decimal()) # 0.2
A Fraction
can be rendered to any arbitrary number of decimal places, but repeating digits will be noted and rendered with overhead dots:
from vinculum import Fraction
print(Fraction(1146408, 364913).decimal(max_dp=999))
# 3.141592653591403978482542414219279663919893234825835199074847977463121346731
# 96076873117702027606580198567877822933137487565529317947017508282796173334466
# 02340831924321687635134949974377454352133248198885761811719505745205021470871
# 13914823533280535360483183662955279751612028072444664892727855680669090988811
# 03167056257244877546154836906331098097354711945038954490522398489502977422015
# 65852682694231227717291518800371595421374409790826854620142335296358310062946
# 51053812826618947529959195753508370488308172084853101972250920082320991578814
# 67637491676098138460400150172780909422245850380775691740223012060408919386264
# 67130521521568154601233718721996749910252580752124478985401999928750140444434
# 70087390693124114514966581075489226199121434424095606350006713929073505191648
# 42030840227670705072167886592146621249448498683247787828879760381241556206547
# 86209315645098968795301893876074571199162540112300740176425613776434382989918
# 14487288751017365783077062203867771222181725507175682971009528298525950020963
print(Fraction(1, 3).decimal())
# 0.̇3
Note that the latter output is 0.̇3
with a dot and not 0.3
.
Full documentation is online at vinculumpy.dev.
Installation
Vinculum requires Python 3.9 or later:
pip install vinculum
Support
Please raise bugs, feature requests and ask questions at github.com/cariad/vinculum/issues.
The Project
Bounden is © 2022 Cariad Eccleston and released under the MIT License at github.com/cariad/vinculum.
The Author
Hello! 👋 I'm Cariad Eccleston and I'm a freelance backend and infrastructure engineer in the United Kingdom. You can find me at cariad.earth, github/cariad, linkedin/cariad and on Mastodon at @cariad@tech.lgbt.
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 Distributions
Built Distribution
Hashes for vinculum-1.0.0b4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6e518d82ccbb136ee8a2ad2274a0cbb859a47d62e8631dcbad66ae177152e45 |
|
MD5 | da6a6d2ff32786e006b57a9f600d74e1 |
|
BLAKE2b-256 | 9646e77f33efc4e26120914b48d75b609d7084f65526c92d11fbbe08bb29e20d |