コード例 #1
0
        public void ValueDoubleUInt32Test(double realValue, UInt32 fixedPointValue, byte wholeBits, byte fractionalBits)
        {
            // The fixedPointValue may have additional bits set which should be ignored when making the real value.  Only the
            // bits that make up the whole and fractional parts are considered.
            //
            fixedPointValue.MakeDouble(wholeBits, fractionalBits).ShouldBe(realValue, Double.Epsilon);

            // Some of our test cases pass in "extra" data in the fixed point value.  This data is ignored, but it means those
            // bits will be 0 when converting from the real value to the FixedPoint so make the value we check again is properly
            // masked from the test data.
            //
            UInt32 maskedFixedPointValue = (UInt32)(fixedPointValue & (UInt32)FixedPoint.FixedPointMask(wholeBits, fractionalBits));

            realValue.MakeFixedPoint <UInt32>(wholeBits, fractionalBits).ShouldBe(maskedFixedPointValue);
        }