Page MenuHomeFeedback Tracker

round alternative syntax for rounding precision
New, NormalPublic

Description

a feature request / wish to have such rounding option with an alternative syntax:

round (2/3) // 1
round [2/3, 0] // 1 - same as round (2/3)
round [2/3, 1] // 0.7
round [2/3, 2] // 0.67
round [2/3, 3] // 0.667
// etc - up to float precision of course.
// negative values (e.g round [2/3, -3]) = ? round to the above?
round [6, -2] // 10?
round [1438, -4] // 1000?

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Operating System Version
2004
Category
Scripting

Event Timeline

7erra added a subscriber: 7erra.Sat, Aug 29, 2:56 AM
LouMontana updated the task description. (Show Details)Sat, Aug 29, 3:03 AM
Leopard20 added a subscriber: Leopard20.EditedSat, Aug 29, 7:42 AM

It is possible to script this on your own.
For example:

round(1e2*2/3)/1e2

Will give you what you wanted for: round [2/3, 2]

A function variant:

MY_fnc_Round = 
{
    params ["_x", "_n"];
    round(10^_n*_x)/10^_n
};
[2/3, 2] call MY_fnc_Round