private static int mod(double x, double y){
	        int r;
	        double d;
	        d = x / y;
	        Double doubleHolder = round(d);
	        r = doubleHolder.intValue();
	        if (r < 0)
	            r--;
	         
	        d = x - y * r;
	        doubleHolder = round(d);
	        r = doubleHolder.intValue();
	        return r;
	    }