How to represent exponentiation in Mikrotik script?
I’m trying to create a script that needs to do an exponentiation, but I couldn’t even find it in the manual. Does anyone know how to represent this?
Example of what I want to do:
:global mask “30”; :for T from=0 to=“n” step=(2 ^ (32-$mask)) do=…
Initially with a new “for” I can do several multiplications, but I would like to simplify the script
What are you trying to accomplish? Scan a network or do some ip/subnet calculations?
There is no exponentiation operator in ROS script, in ROS ^ is used for bitwise XOR operator (see more at Scripting documentation, Operators section), you can create separate function which will calculate with power to avoid nesting.
The specific case of 2x can be implemented as a bitwise shift: 1 << x
Something… can help you http://forum.mikrotik.com/t/rextended-fragments-of-snippets/151033/1