Skip to content
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

Efficient rounding #2

Open
SanjoSolutions opened this issue Jan 1, 2024 · 2 comments
Open

Efficient rounding #2

SanjoSolutions opened this issue Jan 1, 2024 · 2 comments

Comments

@SanjoSolutions
Copy link
Contributor

I have seen some places where a rounded number is required instead of a string.
Here is an efficient implementation of round in Lua: https://github.com/SanjoSolutions/LuaMathematics/blob/fe7048955fb41c03c4cbd6f1dfb94d3b65115d7d/Mathematics.lua#L27-L33
You can copy it.

@derfloh205
Copy link
Owner

hm there is a gutil round already, in what way is it not efficient?

@SanjoSolutions
Copy link
Contributor Author

It converts the number to a string. And when the caller requires a number, the caller seems to convert the string back to a number. That seems computational less efficient than the linked implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants