You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read and understand the suggestion guidelines
Checked for duplicate suggestions
I checked for existing similar suggestions
Summary
Construct currently lacks an expression to round towards zero, which can be useful when dealing with negative numbers. Floor() and ceil() round towards negative and positive infinity. Int() sometimes serves this purpose in other programming languages, but behaves as floor() in construct when used on numbers.
Possible workarounds or alternatives
Flooring the absolute value of a number along with a conditional expression that could be used to identify if the number was originally negative to multiply the result by -1.
n<0?abs(floor(n))*-1:floor(n)
Edit: Or using JavaScript math.trunc() as described in the comments below
Proposed solution
A system expression trunc(n) or truncate(n) would remove the decimals or convert a float to an int, rounding towards 0 regardless of n being positive or negative.
Why is this idea important?
This expression would make rounding towards 0 more accessible and easier to implement for a beginner or otherwise not familiar with programming.
Additional remarks
Appreciate your consideration and thanks for all the work you put into Construct, as always.
The text was updated successfully, but these errors were encountered:
Reviewed guidelines
Checked for duplicate suggestions
Summary
Construct currently lacks an expression to round towards zero, which can be useful when dealing with negative numbers. Floor() and ceil() round towards negative and positive infinity. Int() sometimes serves this purpose in other programming languages, but behaves as floor() in construct when used on numbers.
Possible workarounds or alternatives
Flooring the absolute value of a number along with a conditional expression that could be used to identify if the number was originally negative to multiply the result by -1.
n<0?abs(floor(n))*-1:floor(n)
Edit: Or using JavaScript math.trunc() as described in the comments below
Proposed solution
A system expression trunc(n) or truncate(n) would remove the decimals or convert a float to an int, rounding towards 0 regardless of n being positive or negative.
Why is this idea important?
This expression would make rounding towards 0 more accessible and easier to implement for a beginner or otherwise not familiar with programming.
Additional remarks
Appreciate your consideration and thanks for all the work you put into Construct, as always.
The text was updated successfully, but these errors were encountered: