Tolerance.format_number
- Tolerance.format_number(number, precision=None)[source]
Format a number as a string.
- Parameters:
- numberfloat
The number.
- precisionint, optional
The precision used when converting numbers to strings. Default is
None
, in which caseself.precision
is used.
- Returns:
- str
The formatted number.
Examples
>>> tol = Tolerance() >>> tol.format_number(1.0) '1.000' >>> tol.format_number(1.0, precision=3) '1.000' >>> tol.format_number(1.0, precision=-1) '1' >>> tol.format_number(1.0, precision=-3) '0' >>> tol.format_number(12345, precision=-3) '12300'