Details

      Description

      We'll need to re-implement our round-off algorithm used in latest data, overview and some other places. The current implementation seemed to have deviated from the original idea at some point. Here's a summary of how it works now, omitting some details:

      If units are empty or unit is either %, ms, rpm or RPM
      then:
        If the modulus of the value is >= 0.01 (ZBX_UNITS_ROUNDOFF_THRESHOLD)
        then:
          round it off to 2 (ZBX_UNITS_ROUNDOFF_UPPER_LIMIT) numbers after the decimal point
        else:
          round it off to 6 (ZBX_UNITS_ROUNDOFF_LOWER_LIMIT) numbers
      else
        If the modulus of the value is >= 1 (hardcoded)
        then:
          convert it to some power and add the prefix (K, M, G etc)
          round it off to 2 (ZBX_UNITS_ROUNDOFF_UPPER_LIMIT)
        else:
          round if off to 4 (ZBX_UNITS_ROUNDOFF_MIDDLE_LIMIT) 
      

      I'm not sure about the reasoning behind this algorithm, but I don't think we need two different ways of rounding values depending on their units.

      I believe, the algorithm should be simple and look something like this:

      If the modulus of the value is >= 0.01 (ZBX_UNITS_ROUNDOFF_THRESHOLD)
      then:
        round it off to 2 (ZBX_UNITS_ROUNDOFF_UPPER_LIMIT) numbers after the decimal point
      else:
        round it off to 6 (ZBX_UNITS_ROUNDOFF_LOWER_LIMIT) numbers
      

      We should also consider making these constants configurable from the frontend.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jelisejev Pavels Jelisejevs (Inactive)
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: