public void Test_DoubleToInt64Bits_NaN() { for (int i = 0; i < SIGNIFICAND_WIDTH - 1; i++) { long x = 1 << i; // Strip out sign and exponent bits long y = x & SIGNIF_BIT_MASK; double[] values = { BitConversion.Int64BitsToDouble(EXP_BIT_MASK | y), BitConversion.Int64BitsToDouble(SIGN_BIT_MASK | EXP_BIT_MASK | y) }; foreach (double value in values) { assertTrue("Invalid input " + y + "yielded non-NaN: " + value, double.IsNaN(value)); long converted = BitConversion.DoubleToInt64Bits(value); assertTrue(string.Format("Non-canoncial NaN bits returned: {0:x8}", converted), 0x7ff8000000000000L == converted); } //testNanCase(1 << i); } }
public void Test_DoubleToInt64BitsD() { // Test for method long java.lang.Double.doubleToLongBits(double) double d = double.MaxValue; long lbits = BitConversion.DoubleToInt64Bits(d); double r = BitConversion.Int64BitsToDouble(lbits); Assert.IsTrue(d == r, "Bit conversion failed"); }
public void Test_DoubleToInt64Bits_NegativeInfinity() { assertTrue("Bad conversion for -infinity.", BitConversion.DoubleToInt64Bits(double.NegativeInfinity) == unchecked ((long)0xfff0000000000000L)); }
public void Test_DoubleToInt64Bits_PositiveInfinity() { assertTrue("Bad conversion for +infinity.", BitConversion.DoubleToInt64Bits(double.PositiveInfinity) == 0x7ff0000000000000L); }