static PreciseDecimal fromDouble(final double d)
  {
	if (DPU.isTooBigBase(d))
	{
	  // too big value, the integer part can be lost
	  throw new IllegalArgumentException("Too big value");
	}
	final long intPart = (long) d;
	final double fraction = d - intPart;
	if (fraction == 0.0)
	{
	  return getInstance(intPart, 0);
	}
	final double absValue = Math.abs(d);
	if (absValue < 1.0d)
	{
	  final int fractionalFactor = DPU.findFactorByFLimit(absValue);
	  final int fullFactor = DPU.toFullFactor(fractionalFactor);
	  final int actualFactor = DPU.getFactor(absValue, fullFactor);
	  final int factor = Math.min(fullFactor, actualFactor);
	  final int f = DPU.toFractionalFactor(factor);
	  final double scaledValue;
	  if (f < 0)
	  {
		scaledValue = d * DPU.getScale(factor);
	  }
	  else
	  {
		scaledValue = d * DPU.getMaxIntScale() * DPU.getScale(fractionalFactor);
	  }
	  return safegetInstanceDouble((long) narrow(scaledValue), factor);
	}
	else
	{
	  // find a proper factor according to limits
	  final int intFactor = DPU.findFactorByLimit(intPart);
	  final int actualFactor = DPU.getFactor(absValue, intFactor);
	  final int factor = Math.min(intFactor, actualFactor);
	  final double scaledValue = d * DPU.getScale(factor);
	  return PreciseDecimal.safegetInstanceDouble((long) narrow(scaledValue), factor);
	}
  }