Skip to content

Quantity formatting: Trailing zeros #786

Closed
@pgrawehr

Description

@pgrawehr

The documentation of QuantityFormatter.Format specifies that (and it also behaves like that):

/// "s1", "s2", ..., "sN": The value with N significant digits after the radix followed by the unit abbreviation. For example,
/// "s4" would return "1.2345 m" if <see cref="IQuantity.Value" /> is 1.2345678. Trailing zeros are omitted.

Is there a reason trailing zeros are ommitted? Besides that this constantly changes the length of the output string (if the value changes slightly), it may present a value different from the expectation. For instance, if I have a temperature sensor from which I know it is accurate to 0.01 °C, I would want to use "s2" to print its value with two digits. The output now prints either "20.02 °C" or "20 °C", just because the measurement has slightly changed. Reading the later, I don't know that the measurement was actually "20.00 °C".

For a scientist, it does make a difference whether a reading says "20 °C" or "20.00 °C". I'd like to see an option to force the number of digits to be fixed (much like the "F" default number format specifier does).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions