Пример #1
0
        public void ValueFloatUInt16Test(float realValue, UInt16 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.MakeFloat(wholeBits, fractionalBits).ShouldBe(realValue);

            // 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.
            //
            UInt16 maskedFixedPointValue = (UInt16)(fixedPointValue & (UInt16)FixedPoint.FixedPointMask(wholeBits, fractionalBits));

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