NXLS Script returns bad sum values

Started by Mystery, November 01, 2016, 11:41:04 AM

Previous topic - Next topic

Mystery

Hello guys,

I have one question about scripting in NetXMS. I wrote script, which simply sum three values and return this result.

val1 = GetDCIValueByDescription ...
val2 = GetDCIValueByDescription ...
val3 = GetDCIValueByDescription ...

return val1 + val2 + val3;

When I return val1 or val2 or val3 it returns right number, but when I sum these values, it returns negative incorrect value.
For example val1 = 200.50 val2 = 700.56 and val3 = 1500. When I sum it, it returns -1400 ... That's very strange ...
I thought it could be due to overflow of float value, but somehow it works correctly on different servers with higher values.

Any idea how to solve this or debug this?? Thank you in advance

Mystery

Well,

return val1 / 1000 + val2 /1000 + val3 /1000;

returns correct numbers (/1000 lower ofc), so it has to be something with overflow ...

Mystery

Ok, I solved it by:

return real(GetDCIValueByDescription.....

and also by val1 = real(GetDCI ...