Formatting#
- sigmaepsilon.core.formatting.float_to_str_sig(value: float | Iterable[float], *, sig: int | None = 6, atol: float | None = 1e-07) str | Iterable[str] [source]#
Returns a string representation of a floating point number, with given significant digits.
- Parameters:
- Returns:
String representation of the provided input.
- Return type:
See also
Example
Print the value of pi as a string with 4 significant digits:
>>> from sigmaepsilon.core.formatting import float_to_str_sig >>> import math >>> float_to_str_sig(math.pi, sig=4) '3.142'
- sigmaepsilon.core.formatting.floatformatter(*, sig: int | None = 6) str [source]#
Returns a formatter, which essantially a string temapate ready to be formatted.
- Parameters:
sig (int, Optional) – Number of significant digits. Default is 6.
- Returns:
The string to be formatted.
- Return type:
string
See also
Example
Print the value of pi as a string with 4 significant digits:
>>> from sigmaepsilon.core.formatting import floatformatter >>> import math >>> formatter = floatformatter(sig=4) >>> formatter.format(math.pi) '3.142'