Explore the `decimal` module

We are exposed to the decimal module in one of the Python units (needs attribution). Mind, we’re ankle deep and must needs get into deeper water to really understand this module. This writer is among the ankle deep waders, hence this appeal to other learners to contribute their questions, and advanced learners, their insights on this topic.


>>> import decimal
>>> from math import pi as PI
>>> context = decimal.getcontext().copy()
>>> context.prec = 7
>>> pi = context.create_decimal(PI)
>>> pi
>>> PI
>>> float(pi)

Is there another way to produce a physical value dialed into the precision of the above? Not that I know of. We evidently have a very powerful tool for working with SIGDIGS. The floor is open to discussion…

decimal – Fixed and floating point math