Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

faster round_value #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

faster round_value #2

wants to merge 1 commit into from

Conversation

snabeljoel
Copy link
Contributor

Seems to cut about 1/3 of the time.

The very fastest would simply be floor(num+0.5) with math.floor being cached, but it's only slightly faster than my suggestion. And btw, all of these variations seem to handle negative values perfectly fine in Lua 5.1, contrary to what someone said (? please verify).

Seems to cut about 1/3 of the time.

The very fastest would simply be floor(num+0.5) with math.floor being cached, but it's only slightly faster than my suggestion. And btw, all of these variations seem to handle negative values perfectly fine in Lua 5.1, contrary to what someone said (? please verify).
@bjorn-nesby
Copy link
Contributor

Nice of you to share these optimizations! Will merge when I'm back from vacation :-)
And indeed, I understood that negative values required special handling too.

@snabeljoel
Copy link
Contributor Author

NP. Yeah, but the issue with negative values seems to be a factoid. To be safe, feel free to do a simple test to confirm that it's giving the same results as previously.

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

Successfully merging this pull request may close these issues.

2 participants