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

Support negative coordinates, ie i16, i32, i64 #1

Open
Swoorup opened this issue May 28, 2024 · 2 comments
Open

Support negative coordinates, ie i16, i32, i64 #1

Swoorup opened this issue May 28, 2024 · 2 comments

Comments

@Swoorup
Copy link

Swoorup commented May 28, 2024

One trick is to pre map this coordinates such that the negative minimum start at 0, 0.

@DoubleHyphen
Copy link
Owner

So you're saying to turn the coördinates to offset-binary before encoding them, and then turn them back to one's complement after they're decoded? Hmmmmmmmm… this only entails flipping the most-significant bit, which in turn can be done in one CPU cycle using an XOR. Plus, if we do this after the key has been formed, we could XOR them all at once using a suitable bit-mask.

I guess either of us could do it. Do you have a specific use-case in mind, or are you speaking more generally?

@Swoorup
Copy link
Author

Swoorup commented Jun 4, 2024

Yeah just in general working with negative coordinates, nothing specific. I am currently using a gist I created instead, due to other issue (performance). Using magic bytes instead of generating them by code appears to create an optimal assembly.

https://godbolt.org/z/deeaanjbW

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