simplebench.utils.significant_figures module🔗
Utility functions for significant figures handling.
- simplebench.utils.significant_figures.sigfigs(number: float, figures: int = 3) float[source]🔗
Rounds a floating point number to the specified number of significant figures.
If the number of significant figures is not specified, it defaults to
DEFAULT_SIGNIFICANT_FIGURES.14.2 to 2 digits of significant figures becomes 14
0.234 to 2 digits of significant figures becomes 0.23
0.0234 to 2 digits of significant figures becomes 0.023
14.5 to 2 digits of significant figures becomes 15
0.235 to 2 digits of significant figures becomes 0.24
- Parameters:
- Raises:
TypeError – If the
numberarg is not a float or thefiguresarg is not an int.ValueError – If the
figuresarg is not at least 1.
- Returns:
The rounded number as a float.
- Return type: