public static NormalisedDecimal create(BigInteger frac, int binaryExponent) {int pow10;if (binaryExponent > 49 || binaryExponent < 46) {int x = (29 << 19) - binaryExponent * LOG_BASE_10_OF_2_TIMES_2_POW_20;x += C_2_POW_19; pow10 = -(x >> 20);} else {pow10 = 0;}MutableFPNumber cc = new MutableFPNumber(frac, binaryExponent);if (pow10 != 0) {cc.multiplyByPowerOfTen(-pow10);}switch (cc.get64BitNormalisedExponent()) {case 46:if (cc.isAboveMinRep()) {break;}case 44:case 45:cc.multiplyByPowerOfTen(1);pow10--;break;case 47:case 48:break;case 49:if (cc.isBelowMaxRep()) {break;}case 50:cc.multiplyByPowerOfTen(-1);pow10++;break;default:throw new IllegalStateException("Bad binary exp " + cc.get64BitNormalisedExponent() + ".");}cc.normalise64bit();return cc.createNormalisedDecimal(pow10);}
public static NormalisedDecimal Create(BigInteger frac, int binaryExponent){int pow10;if (binaryExponent > 49 || binaryExponent < 46){int x = (29 << 19) - binaryExponent * LOG_BASE_10_OF_2_TIMES_2_POW_20;x += C_2_POW_19; pow10 = -(x >> 20);}else{pow10 = 0;}MutableFPNumber cc = new MutableFPNumber(frac, binaryExponent);if (pow10 != 0){cc.multiplyByPowerOfTen(-pow10);}switch (cc.Get64BitNormalisedExponent()){case 46:if (cc.IsAboveMinRep()){break;}goto case 44;case 44:case 45:cc.multiplyByPowerOfTen(1);pow10--;break;case 47:case 48:break;case 49:if (cc.IsBelowMaxRep()){break;}goto case 50;case 50:cc.multiplyByPowerOfTen(-1);pow10++;break;default:throw new InvalidOperationException("Bad binary exp " + cc.Get64BitNormalisedExponent() + ".");}cc.Normalise64bit();return cc.CreateNormalisedDecimal(pow10);}