Possilbe bug: Float DCI values below 1 display unnecessary trailing zeroes with

Started by Egert143, Today at 01:07:42 PM

Previous topic - Next topic

Egert143

Float DCI values between approximately 0.01 and 1 are displayed with unnecessary trailing zeroes when using a measurement unit with default multipliers.

For example, I am monitoring current from a PDU over SNMP.

The SNMP device returns integer values that are divided by 100 using a transformation script:

return $1 / 100;

For a phase current:

Raw value: 303
Transformed value: 3.03
Displayed value: 3.03 A

This is displayed correctly.

However, for the neutral current:

Raw value: 68
Transformed value: 0.68
Displayed value: 0.680000 A

The expected display value would be:

0.68 A
Configuration
NetXMS server/client version: 6.1.1
DCI type: SNMP
Data type: Float
Unit: A
Multipliers: Default
Transformation:
return $1 / 100;
Steps to reproduce
Create an SNMP DCI returning an integer value such as 68.
Set the DCI data type to Float.
Set the measurement unit to A.
Leave multipliers at the default setting.
Add the transformation:
return $1 / 100;
The transformation test correctly shows 0.68.
After normal data collection, Last Values displays:
0.680000 A

Using the same configuration with a raw value such as 303 produces:

3.03 A

as expected.

I also duplicated a working DCI that displayed 3.03 A correctly and changed only the SNMP OID so that the returned/transformed value was below 1. The duplicated DCI immediately showed the same 0.680000 A behavior, so the issue does not appear to be caused by a DCI configuration difference.

Expected behavior

Float values should use consistent formatting regardless of whether the value is above or below 1.

For example:

3.030000 -> 3.03 A
0.680000 -> 0.68 A
Actual behavior

Values greater than or equal to 1 are formatted without unnecessary trailing zeroes:

3.030000 -> 3.03 A

while values below 1 may retain the complete float string:

0.680000 -> 0.680000 A
Additional information

The behavior appears to still be present in the DataFormatter implementation in NetXMS 6.2.3 and current master.

It appears that when the default multiplier logic cannot select a multiplier for a value below 1, the original value string is retained instead of being converted to a Double. The %s formatting path then only applies the normal decimal formatting when the value is a Double, causing the original 0.680000 string to be displayed unchanged.

The underlying numeric DCI value appears to be correct; this seems to be a display/formatting issue.