-
Notifications
You must be signed in to change notification settings - Fork 70
RFC: math.truncate #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
RFC: math.truncate #152
Conversation
|
This RFC aligns with an RFC I made a while back that was rejected, however, your proposal does a great job of "answering" the reasons why mine was rejected. Would be happy to see this happen. |
|
You can already achieve number truncation with Furthermore, it is trivial to construct a function that truncates to a specific decimal digit with this, which is what I assume you mean by the term "idp" in the RFC. local function truncate(value: number, digits: number): number
local factor = 10 ^ digits
return math.modf(value * factor) / factor
endThe only value a new standard function could bring is streamlining arbitrary digit truncation, which I do not believe is a common enough operation to justify addition. |
Since that one returns a tuple, What happens to the the second tuple in memory? Does it just get reliably garbage collected? |
Luau does not have tuples. |
Ah, I see. Tuples to me are just a list of values, not sure if it has any other meanings.
Is |
math.truncateit cuts off digits after the decimal point, without having to usemath.floorormath.clamp.🤔
Render