[ZBX-8771] Remake the value round off algorithm Created: 2014 Sep 17  Updated: 2019 Dec 10

Status: Open
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.4.0
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Pavels Jelisejevs (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: latestdata, overview, rounding, units
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate

 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.



 Comments   
Comment by richlv [ 2014 Oct 10 ]

paavel's suggestion seems reasonable and that is how it was supposed to work

Generated at Thu Apr 25 16:43:49 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.