Transformation script - math calculations
-
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.001384So my question is, how the hell did I get this value?
Cheers,
Iliyan -
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 -
Thanks Victor. This works like a charm.
Iliyan
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login