'Why am I unable to show the precision of a float value using quantiphy and engfmt?

I'm working on an engineering calculator in python and I found some packages that can convert a float value to engineering notation. First I installed engfmt:

Code:

from engfmt import to_eng_fmt

num = -327.2051
num = to_eng_fmt(num, prec=4)
print(num)

Output:

-327.21

The second package that I installed is quantiphy because it is a new release and serves the same purpose as the engfmt :

Code:

from quantiphy import Quantity

num = -327.2051
num = Quantity(num).fixed(prec=4)
print(num)

Output:

-327.21

What I want is to show the precision decimal value upto 4 places. like this -327.2051

Version:

  • Python == 3.7.9
  • quantiphy == 2.12.0
  • engfmt == 0.2.0 (I cant install the version 1.1.0 because it gives me an error. This version only works for me)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source