class Geobox {

    protected static long getHashIterative(float major, float minor, final int bits) {
        // initial values,
        // start with -180..180 longitude
        long hash = 0;
        float temp;
        for (int b = bits, i = 0; 0 <= b; b--, i++) {
            temp = minor;

            if (major < 0f) {
                minor = major + D_MAJOR[i+1];
            }
            else {
                hash |= 1L << b;
                minor = major - D_MAJOR[i+1];
            }
//            LOG.debug("bit {}, maj {}, dM {} hash 0b{} 0x{}", new Object[] {
//                Integer.toString(b), Float.toString(major), Float.toString(D_MAJOR[i]), 
//                Long.toBinaryString(hash), Long.toHexString(hash)});
            
            major = temp;
        }
        return hash;
    }

}