We submit this proposal to address one of the oldest and most restrictive limitations in the RouterOS Scripting language (RSC): the lack of native support for floating-point numbers (Float or Decimal). The primary objective is to enable engineers to perform accurate and reliable calculations, which are fundamental to modern network management.
2. The Current Problem: An Obsolete Limitation
RouterOS Scripting’s dependence on only Integers for arithmetic has been a significant weakness for years. In today's programming landscape, floating-point support is considered table stakes (a basic, expected feature). This constraint forces your users to:
Lose Critical Precision: Any division operation that doesn't yield an integer results in truncation (the fractional part is simply dropped), leading to inaccurate results for sensitive calculations like bandwidth usage percentages, performance averages, and timing functions.
Employ Obsolete Workarounds: Developers must resort to complex, time-consuming, and hard-to-read techniques (such as multiplying by 1000 and dividing back later) to simulate precision. This significantly slows down development and increases the potential for coding errors.
The Limitation Example: If x = 5, the expression x / 2 currently evaluates to 2 (losing 0.5), instead of the required 2.5.
3. Proposed Solution (Native Float Support)
We urge the development team to introduce a dedicated data type for floating-point numbers into the RouterOS scripting language.
This vital upgrade will:
Ensure accurate and reliable computational results suitable for a production networking environment.
Allow scripts to handle quantifiable data such as precise percentages and time measurements (sub-second values).
Align the language with current industry expectations and automation tool standards.
4. Conclusion
Addressing this long-standing limitation by supporting Float Numbers, alongside the previously proposed Compound Operators, will represent a major leap forward in the capabilities of RouterOS scripting. We highly recommend prioritizing this fundamental and overdue feature to enhance the control and automation power for network engineers globally.
I've already told you that RouterOS scripting isn't a programming language for creating programs as it's commonly understood.
It's precisely your perspective that's wrong from the start.
Although, obviously like more than ten years ago, I completely agree with the request.
Well, they've implemented exit/break/continue in just 15 years after request. So, probably we need to wait just another 5 years for floating point numbers...
Please note that not all processor that RouterOS runs on have FPU. The old hEX with MT7621A for example doesn't. On all those devices a software emulated floating point library will have to be added to the routeros package and will be orders of magnitude slower than integer math.
We cannot obtain a decimal by calculating an expression like 2.5/2 ,it will round to integer 1 ;
but system can accept the command like :beep length=1.25; Very magical !
If I want to perform operations precise to decimals in the script,need to write a complex script to convert the format , but sometimes the conversion cannot solve it;