Skip to content

Trace: round(#1, to N dp) names no unit when the value's unit has no symbol #15

Description

@christianparpart

What happens

Take a rounding to decimal places of a quantity declared in a dimensioned unit that has no symbol. For example a mass in a unit of 1/1000 kg with no symbol, rounded to 2 places. Its trace line is shaped like this (illustrative):

2. round(#1, to 2 dp) = 3/1000 kg

The rounding was to 2 places of the unnamed unit. But the line names no unit for the places, and the value after it reads in kilograms (the coherent unit, which #12 writes after such a value). So "2 dp" reads as two decimal places of a kilogram, which is not what happened.

The cause is in include/formula-cpp/trace_render.hpp. The StepKind::Round case calls rounding_call_text(…, unit_symbol_text(shownStep.unit)). For a unit with no symbol that text is empty, and rounding_call_text then writes no unit clause ("No unit clause for a unit with no symbol"). Meanwhile value_in_declared_unit shows the value in the coherent unit with its spelling.

Expected

The line says what the decimal places count in, and stays consistent with the value written after it. Either:

  • the unit clause names the unit the places are counted in, spelled the way the line can name it; or
  • the line says that the places count in a unit with no symbol, and gives that unit's relation to the unit the value is shown in.

The same applies to the rounding forms that share rounding_call_text: rounded roots, rounded opaque outputs, and rounded transcendental functions.

Test

A rounding to 2 places of a quantity in a unit with no symbol (UnnamedGram in test/trace_shown_unit_tests.cpp is such a unit). Its line must not let "2 dp" be read as places of the coherent unit.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions