NetXMS Support Forum

English Support => General Support => Topic started by: Mystery on November 01, 2016, 11:41:04 AM

Title: NXLS Script returns bad sum values
Post by: Mystery on November 01, 2016, 11:41:04 AM
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
Title: Re: NXLS Script returns bad sum values
Post by: Mystery on November 01, 2016, 12:20:29 PM
Well,

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

returns correct numbers (/1000 lower ofc), so it has to be something with overflow ...
Title: Re: NXLS Script returns bad sum values
Post by: Mystery on November 02, 2016, 08:48:26 AM
Ok, I solved it by:

return real(GetDCIValueByDescription.....

and also by val1 = real(GetDCI ...