Page MenuHomeFeedback Tracker

round command does not work properly on calculated results
New, NormalPublic

Description

When trying to round the result of a calculation directly, then the round command does not round to the next integer, if the whole term is not covered in parantheses. When saving the result of the calculation in a variable and then do a round on the variable it works fine.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
General
Steps To Reproduce

Simple example for a wrong result

round (3+4)/3 -> 2.33333

but

round ((3+4)/3) -> 2

and

_calc = (3+4)/3
round _calc -> 2

gives the correct result.

Event Timeline

Ron4Swat created this task.Aug 8 2020, 12:13 PM
Ron4Swat edited Steps To Reproduce. (Show Details)
Leopard20 added a subscriber: Leopard20.EditedAug 8 2020, 2:10 PM

It's not a bug. That's how the expressions are prioritized.
round (3+4)/3 calculates round (7) first, then divides it by 3.

https://community.bistudio.com/wiki/SQF_syntax#Rules_of_Precedence

My bad, never had any issues so far with this detail of SQF.