round() function bug

round() function bug

Scoox
Collaborator Collaborator
804 Views
2 Replies
Message 1 of 3

round() function bug

Scoox
Collaborator
Collaborator

The following expressions produce different results:

 

round(4) * 1 mm = 4
round(4 mm) = 0

round(5) * 1 mm = 5
round(5 mm)  = 10

round(15.2) * 1 mm = 15
round(15.2 mm)  = 20

As you can see, when the units are inside the brackets, Fusion rounds to the nearest 10 rather than the nearest whole number. This doesn't seem to happen with other functions such as abs(). The workaround is to ensure the units are outside the brackets.

 

The following screenshot shows the actual results in Fusion:

 

Round function problem.png

 

Why this is a big problem: If the argument to the round() function is a variable, the value assigned to the variable will usually be a dimension with units, e.g. 5 mm, which also causes the problem to happen:

 

WasherThickness = 0.8 mm
WasherSocketDepth= round(WasherThickness+0.2)  * 1 mm

In this case putting the units outside the brackets doesn't work becasue the variable already has its own units, which would results in mm²:

 

WasherThickness = 0.8 mm
WasherSocketDepth= round(WasherThickness+0.2) * 1 mm ; Error!

Thanks!

0 Likes
Accepted solutions (1)
805 Views
2 Replies
Replies (2)
Message 2 of 3

jeff_strater
Community Manager
Community Manager
Accepted solution

Yes, this is a known issue.  Originally, these functions were assumed to always get "unitless" inputs.  So, they did not work correctly with length parameters.  This is being actively enhanced to allow them to be units aware.  Once this fix is released, "round(4.2 mm)" will work as expected, and return "4.0 mm".

 


Jeff Strater
Engineering Director
0 Likes
Message 3 of 3

Scoox
Collaborator
Collaborator
Thanks Jeff
0 Likes