### Question:
FloatFormat { static double createFloat(boolean sign, long mantissa, int exp) { exp += 1023; long bits = mantissa >>> 11; if (exp == 0) { bits = bits >> 1; } else { bits = bits & 0xfffffffffffffL; } bits |= (long) exp << 52; if (sign) { bits |= 0x8000000000000000L; } return Double.longBitsToDouble(bits); } FloatFormat(int sz); int getSize(); double getHostFloat(long encoding); BigDecimal getHostFloat(BigInteger encoding); long getEncoding(double host); BigInteger getEncoding(BigDecimal value); long opEqual(long a, long b); BigInteger opEqual(BigInteger a, BigInteger b); long opNotEqual(long a, long b); BigInteger opNotEqual(BigInteger a, BigInteger b); long opLess(long a, long b); BigInteger opLess(BigInteger a, BigInteger b); long opLessEqual(long a, long b); BigInteger opLessEqual(BigInteger a, BigInteger b); long opNan(long a); BigInteger opNan(BigInteger a); long opAdd(long a, long b); BigInteger opAdd(BigInteger a, BigInteger b); long opSub(long a, long b); BigInteger opSub(BigInteger a, BigInteger b); long opDiv(long a, long b); BigInteger opDiv(BigInteger a, BigInteger b); long opMult(long a, long b); BigInteger opMult(BigInteger a, BigInteger b); long opNeg(long a); BigInteger opNeg(BigInteger a); long opAbs(long a); BigInteger opAbs(BigInteger a); long opSqrt(long a); BigInteger opSqrt(BigInteger a); long opInt2Float(long a, int sizein); BigInteger opInt2Float(BigInteger a, int sizein, boolean signed); long opFloat2Float(long a, FloatFormat outformat); BigInteger opFloat2Float(BigInteger a, FloatFormat outformat); long opTrunc(long a, int sizeout); BigInteger opTrunc(BigInteger a, int sizeout); long opCeil(long a); BigInteger opCeil(BigInteger a); long opFloor(long a); BigInteger opFloor(BigInteger a); long opRound(long a); BigInteger opRound(BigInteger a); static final BigDecimal BIG_NaN; static final BigDecimal BIG_POSITIVE_INFINITY; static final BigDecimal BIG_NEGATIVE_INFINITY; final BigDecimal maxValue; final BigDecimal minValue; }### Answer:
@Test public void testCreateFloat() { double x = 4.5; FloatData data = FloatFormat.extractExpSig(x); double y = FloatFormat.createFloat(data.sign, data.mantisa, data.exp); Assert.assertEquals(x, y, 0); x = -4.5; data = FloatFormat.extractExpSig(x); y = FloatFormat.createFloat(data.sign, data.mantisa, data.exp); Assert.assertEquals(x, y, 0); x = 0.00000000000000000000000045; data = FloatFormat.extractExpSig(x); y = FloatFormat.createFloat(data.sign, data.mantisa, data.exp); Assert.assertEquals(x, y, 0); x = -0.000000000000000000000000045; data = FloatFormat.extractExpSig(x); y = FloatFormat.createFloat(data.sign, data.mantisa, data.exp); Assert.assertEquals(x, y, 0); }