Package: esoteric-sigdigs
esoteric-sigdigs🐍 A Python package that detects and rounds numbers to significant digits.This package aims to provide easy-to-use functions to work with significant digits (also known as significant figures).⚠ Please note that this package is almost certainly laced with bugs, so use it at your own risk! Additionally, the significant digit rules used may not be exactly what you are looking for; I have designed this package to fit the likely-esoteric way I have been taught to use significant digits. Sorry! If you encounter any issues, please create an issue on GitHub (https://github.com/ericli3690/esoteric-sigdigs) or email me atericli3690@gmail.com.🛠 Installation and Use>> pip install esoteric-sigdigsfromsigdigsimportfunction_name_herefunction_name_here(arguments_here)🧪 What is Scientific Notation?Scientific notation is often used by this package, a string formatting of numbers which takes the following form:a.bcdEfAnd which can be written in standard formatting asa.bcd * 10^fIt can be seen that f represents the exponent.Here are some more examples, shown in scientific notation while pretending that trailing zeros are NOT significant (this is not how functions likestandard_to_scientificin this package actually behave!):Standard FormattingScientific Notation1234561.23456E51200001.2E5-0.0000056-5.6E-6101E188E01000000000001E11⚙ Functionality🟥 sigdigs(*vals:float) -> intReturns the number of significant digits of a provided float.Given a list of numbers, it returns the lowest significant digits number provided by any of the floats in the list.Trailing zeros are considered significant.Zeros are considered to have one significant digit.Examples:InputOutput123.4566100.040.000562-3424000411010.0001123.456, 100.0, 0.00056, -34, 40002🟨 round_to_sigdigs(val:float, sig:int) -> strRounds a float to an integer number of significant digits.Always returns answers in scientific notation.Examples:ValueSigdigsOutput3.25553.2550E0-8.331-8E00.005616E-31234.567821.2E3040E00.00090E0🟩 scientific_to_standard(val:str) -> str:Converts a number in scientific notation to normal formatting, IF POSSIBLE.Sometimes, converting to normal formatting would involve adding extra significant digits (ex. 1.2E3 cannot be rewritten as 1200, as this would involve adding two new significant digits).In these cases, this function will simply return the input.Examples:Scientific NotationStandard Formatting1.23456E51234561.2E51.2E5-5.6E-6-0.00000561.0E1108E081E111E110E00🟩 standard_to_scientific(val:float) -> str:The inverse of the above operation!Converts a float into scientific form.Examples:Standard FormattingScientific Notation1234561.23456E51200001.20000E5-0.0000056-5.6E-6101.0E188E01000000000001.00000000000E1100E0🟦 round_to_sigdigs_and_standard_form_given_source(val:float, sigsource:list) -> str:This is a common routine that I personally find useful.Imagine a calculation being performed...V = lwh

l = 50.0
w = 0.02345
h = 10

V = 11.725... but to how many significant digits?This routine usesscientific_to_standard,round_to_sigdigs, andsigdigsto solve this efficiently.For example, for this question, to obtain V with proper significant digits:round_to_sigdigs_and_standard_form_given_source(50.0 * 0.02345 * 10, [50.0, 0.02345, 10])Which outputs12, as expected.