Skip to content

Commit

Permalink
Fix GEOHASH negative shifting in a more compatible way.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Dec 18, 2019
1 parent e6e58e4 commit 5a72c50
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/geo.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,15 @@ void geohashCommand(client *c) {
char buf[12];
int i;
for (i = 0; i < 11; i++) {
int idx = (hash.bits >> (52-((i+1)*5))) & 0x1f;
int idx;
if (i == 10) {
/* We have just 52 bits, but the API used to output
* an 11 bytes geohash. For compatibility we assume
* zero. */
idx = 0;
} else {
idx = (hash.bits >> (52-((i+1)*5))) & 0x1f;
}
buf[i] = geoalphabet[idx];
}
buf[11] = '\0';
Expand Down

0 comments on commit 5a72c50

Please sign in to comment.