When using the Round() function, the result always seems to be a decimal, even if the decimal places are set to 0.
Formula:
Round(5.4321, 0)
Expected Result:
5
Actual Result:
5.0
When using the Round() function, the result always seems to be a decimal, even if the decimal places are set to 0.
Formula:
Round(5.4321, 0)
Expected Result:
5
Actual Result:
5.0
The round function is merely rounding the number, it does not change the display of the number, so in this case you have the result (=5) being shown with 1 decimal place.
You can change the number of decimal places to show when you configure the number field:
I was trying to use it within in a formula in combination with left(), which requires an integer, so the decimal places setting doesn’t help.
Left(“--------------------------------------------------”,50 - Round(Length(Name) * 3.5, 0))
Would work if Round() was honoring the 0 decimal place, but I get the following error:
“Expected argument of type ‘Integer’ but ‘Decimal’ found.”
If I use 2 separate formulas:
Name Length =
Round(Length(Name) * 3.5, 0)
where the decimal places is manually set to 0 like your example
and
Separator =
Left(“--------------------------------------------------”,50 - [Name Length])
It works, but I feel like I shouldn’t have to use 2 formulas because round() should be respecting the 0 decimal place setting that was set in the function.
The round() function has to use decimal as the returned data type, since it can be used to return any number of decimal places.
The solution is either for the left() function to accept a decimal (but cast it to integer) or for there to be a new explicit decimal-to-integer function.
Thanks for the explanation @Chr1sG