Skip to main content

A package for creating and manipulating floating point numbers accounting for significant figures

Project description

pysigfig

A package for creating and manipulating floating point numbers accounting for significant figures

Python package PyPI version

Quickstart

import math

import pysigfig as pysf


# a number with 4 singificant digits
x = pysf.Float("1.234")
# a number with 3 significant digits
y = pysf.Float("31.1")

z1 = x + y
z2 = x * y

# z1 should have tenths digit as the least significant
print(z1)
# z2 should have 3 significant digits
print(z2)

area = pysf.Const(math.pi) * pysf.Float("2.0")**2
# area should have 2 significant digits
print(area)

References

For a simple overview of arithmetic with significant figures, see the Wikipedia Page.

Methods of Entry

# Enter a floating point number and specify the number of significant digits
pysf.Float(1.2345, 2)
pysf.Float(1.2, 8)

# Enter the string representation
pysf.Float("1.23") # 3 sig figs
pysf.Float("1.230000") # 7 sig figs
pysf.Float("0.0045") # 2 sig figs
pysf.Float("100000") # 6 sig figs
pysf.Float("1.0E+06") # 2 sig figs

# Enter a constant
pysf.Const(2)
pysf.Const(math.pi)

Limitations

pysigfig cannot accept a string like "100000" and assign only one significant digit to it. However, this can be entered in scientific notation or as a float.

# Enter 100000 with 1 significant figure
pysf.Float("1E+05")
pysf.Float(100000, 1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysigfig-0.0.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysigfig-0.0.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file pysigfig-0.0.2.tar.gz.

File metadata

  • Download URL: pysigfig-0.0.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for pysigfig-0.0.2.tar.gz
Algorithm Hash digest
SHA256 70c8eabf919f214349dd3d366bbc54741ecdcca7f032b1168711cb53fddf4faf
MD5 8818b8f34d9fedd6f05cbbbda92098a0
BLAKE2b-256 a75d7fc7b2f3d095e0aa6518f6e4c379aaaec3f8c5c80208bc7491cfad33f4fc

See more details on using hashes here.

File details

Details for the file pysigfig-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pysigfig-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1

File hashes

Hashes for pysigfig-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b6129a64a1623afd286c07f16eca2a7056168fbe31aab5f0a85c887d31b7050f
MD5 f7ab12d3ac000ce7e8af40d9e38abad0
BLAKE2b-256 c71221898cc50558602919c6f5ec09dafb8615130db2f5be725c2cd6a584d5f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page