Esempio n. 1
0
        public void ValueFloatInt16Test(float realValue, Int16 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.
            //
            Int16 maskedFixedPointValue = (Int16)(fixedPointValue & (Int16)FixedPoint.FixedPointMask(wholeBits, fractionalBits));

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