Transformation script - math calculations

Started by Iliyan Vutov, October 14, 2015, 03:26:02 PM

Previous topic - Next topic

Iliyan Vutov

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

Victor Kirhenshtein

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

Iliyan Vutov

Thanks Victor. This works like a charm.

Iliyan