static int getFactor(final double d, final int max)
  {
	if (d == 0)
	{
	  return 0;
	}
	int factor = 0;
	do
	{
	  final double scale = getDScale(factor);
	  final double scaled = d * scale;
	  if (scaled == (long) scaled)
	  {
		return factor;
	  }
	  else
	  {
		factor++;
	  }
	}
	while (factor < max);
	return max;
  }