public static long compareKeys(int[] key1, int[] key2) throws pval_error, make_key_error
	{
		int i=keyLength-1;
		long pval=1,dist=0;
		if (i==-1) return 0;
		long dec=(long)Math.pow(2,b);
		pval=(long)Math.pow(2,keyLength*b);
		//outputtoScreen("\nStarting pval="+pval);
		for (int j=0;j<=i;j++)
		{
			pval=pval/dec;
			if (pval==0)
			{
				System.out.println("\nError: pval = 0 j="+j+"keyl="+keyLength);
				//Thread.dumpStack();
				throw new pval_error();
			}
			if (key1[j]<0 || key2[j]<0) throw new make_key_error();
			dist+=pval*((long)(key1[j]-key2[j]));
			
		}
		if (pval!=1)
		{
			System.out.println("\nError: pval != 1 pval="+pval);
			//Thread.dumpStack();
			throw new pval_error();
		}
//		int half=(long)Math.pow(2,bkeyLength-1);
//		if (dist>half)
//			dist=(-1)*(dist%half);
//		else if (dist<(-1)*half)
//			dist=(-1*dist)%half;
		if (dist>common.maxN) throw new make_key_error();
		return dist;
	}