Category Archives: Locis

Large Binary Numbers in Javascript

Have you ever wondered what the largest number is?  At one point it was a googolplex, but unless you write a custom class to deal with really large numbers, your dev environment will never count to a googolplex.

For I am reworking a geohash encoding algorithm today, and I wanted to see what Javascript could handle.  Strongly typed languages like Java have known upper limits, but languages like javascript are a bit more mysterious, so the only way to know is to find out.  I wrote this function to test it, and I ran it in the firebug console on a random webpage ( firebug won’t work unless the DOM is ready ).

for( i = 0 ; i < 500 ; i++){
    var value = Math.pow(2,i) +1;
    console.log (   i + "n" +
    value + "n" +  

The output finally looks like this, and reveals that 2^52 is the largest number you can add 1 to and still represent it as an integer. Any larger and javascript will just use it as a float, and you will not have a sufficient number of bits to represent it.  I wonder if this is the same in all browser/ os combination pairs?





So in this circumstance, javascript seems to have 54 bits of integer accuracy, a few short of a LONG 64 bit int, or IEEE 80 bit notation.

Test it yourself, and let me know.


About is a short url service that creates location aware hashes.  The initial prototype of was created during the fall 2009 LA Startup weekend.  The idea was pitched by Justin Kruger, and was created with the help of Alexis Eller, and Andrew…. uses geolinks to represent geographic areas on a map.  Each geolink may be accurate enough to describe something like a region, city, or street address.  We can even define a specific GPS coordinate with about 12 characters that you can share in your tweets, on your blog, or in your text messages to friends.  Geolinks are especially neat because you can vary the precision of the defined area by removing characters from the end of the link.   Because of this special attribute, geo hashes are easily compared and hierarchically grouped, so a computer might be able to find all of the geohashes that are within a city just by comparing strings; no calculation is necessary.

The geohash algorithm has a few other improvements over the one found at, for one, our hashes dedicate the 1st character to defining the longitudinal region.  We use 1 of 64 possible characters in each character position thus breaking the earth into 64 vertical regions.  We even put the 1st region at the international dateline to make time calculations easier.  The idea here is that if your geohash was only one character long, or you/ your computer only wanted to look at the first character, it could then roughly approximate which time zone the remaining characters are in.  Using the 1st, and 2nd character, you should be able to define a region the size of Kansas.  Together the 1st two characters define 4,096 regions on earth ( 64×64 ).  The remaining characters work a bit differently and work more like a traditional geohash.  Each character in the hash describes with increasing precision an area inside of one of those 4,096 regions.  Using 5 or 6 characters should define about the size of a city, and 12 characters the area of a laptop computer.

Because geolinks, are both a geohash, and a hyperlink, we can collect interesting stats on who is visiting a given region, and we can crawl the web and twitter to see what people are saying about a given reason.  Think of it as a sort of pageRank for location on the web.  And because it’s a hierarchical data format, any shorter url can include the information from all of the locations that it contains.

We plan to have a lot of fun with taking the site further, how would you want to use the site?  Please provide us feedback through the Uservoice link on the left hand side and we would love to add interesting features.