NetXMS Support Forum

English Support => General Support => Topic started by: Iliyan Vutov on October 14, 2015, 03:26:02 PM

Title: Transformation script - math calculations
Post by: Iliyan Vutov on October 14, 2015, 03:26:02 PM
Hi,

I'm trying to do simple math calculations in order to show correct used disk space. The value I'm taking it from SNMP and then I'm doing a simple transformation as follows:


sub main()
{
return 4096 * $1 / 1099511627776;
}


For example when $1 is equal to 1265236238 (which is actual value in my case), the result should be similar to 4.7133.
However it shows -0.001384

So my question is, how the hell did I get this value?

Cheers,
Iliyan
Title: Re: Transformation script - math calculations
Post by: Victor Kirhenshtein on October 16, 2015, 07:14:25 PM
Hi,

seems that NXSL identifies value in $1 as 32 bit and so does 32 bit arithmetic. Changing it to


return 4096 * int64($1) / 1099511627776;


should help.

Best regards,
Victor
Title: Re: Transformation script - math calculations
Post by: Iliyan Vutov on October 19, 2015, 07:55:24 PM
Thanks Victor. This works like a charm.

Iliyan