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

Consider using bit-packed vector for storing coordinates #2468

Closed
3 tasks
danpat opened this issue May 26, 2016 · 2 comments
Closed
3 tasks

Consider using bit-packed vector for storing coordinates #2468

danpat opened this issue May 26, 2016 · 2 comments
Labels

Comments

@danpat
Copy link
Member

danpat commented May 26, 2016

Currently, we're using int32_t to store lat/lon values, and we're capping at 6 decimal places of precision (gives us around 10cm precision at the equator, and better elsewhere)

This means that we have known min/max values, and we're probably not using the entire 32bit space. There's an opportunity here to save a bit of memory.

value integer value binary pattern for integer
179.999999 179999999 0000 1010 1011 1010 1001 0100 1111 1111
-179.999999 -179999999 1111 0101 0100 0101 0110 1011 0000 0001
89.999999 89999999 0000 0101 0101 1101 0100 1010 0111 1111
-89.999999 -89999999 1111 1010 1010 0010 1011 0101 1000 0001

So, it looks like we need 28 bits for longitude, 27 bits for latitude, and 1 additional bit for sign. We could save 9% space (1-29/32) for longitude coordinate storage, and 12.5% for latitude storage.

Bit 31 is currently the sign bit. Bits 27/28 to 30 are unused for coordinate data, except that negative numbers are encoded using two's complement representation. We would need special handling for this to maintain the sign bit and proper encoding.

Todo:

  • evaluate large-scale memory usage to see if 9% saving here is worthwhile
  • measure performance impact of additional bit-packing logic for coordinate access
  • do it

/cc @TheMarex @lbud

@daniel-j-h
Copy link
Member

except that negative numbers are encoded using two's complement representation.

impl. defined :/ http://eel.is/c++draft/basic.fundamental#7

Copy link

github-actions bot commented Jul 8, 2024

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Jul 8, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants