User talk:Newacct

From Geohashing

Hi Newacct,

I noticed your change on MediaWiki Implementation. I came to the conclusion that you probably wanted to write

    $dec = hexdec($md5);

as the $md5 variable is being re-used and replaced by the selected half. Using substr again would result in an empty string. I'm not familiar with the implementation, and wouldn't want to understand that guesscode anyway, so I'll leave it to you to figure out if I am correct. -- relet 13:22, 11 August 2010 (UTC)


hexdec will give you an integer, you would still need to divide it to get the correct result, so imho it should be
 $dec = hexdec($md5) / pow(16,15);

--Crox 20:17, 11 August 2010 (UTC)

But dividing by 16^15, doesn't that just basically drop the last 15 hex digits? --Newacct 04:51, 12 August 2010 (UTC)
when that line of code is executed, $md5 already contains only 15 characters (see previous substr). you want a number between 0 and 1, to add it to your latitude resp. longitude. if you had only one hex digit (between 0 and f), you would first convert it into an integer (ie between 0 and 16) and then divide it by 16, right? if you had two (ie between 00 and ff), you would convert to an integer and then divide by 256, or 16x16. now we have 15 digits, hence we convert to an integer then divide by 16^15. (we are using only 15 chars out of 16 precisely because of issues with very big integers.) --Crox 21:19, 12 August 2010 (UTC)