public void MulTest()
        {
            var f1 = Fix.CreateDecimal(12, 25, 2);
            var f2 = Fix.CreateDecimal(123, 75, 2);

            FixAssert.AssertEquals(f1 * f2, 12.25f * 123.75f, Epsilon);
        }
Example #2
0
        public void SqrtAverageDeviationTest()
        {
            var maxDiff = double.MinValue;

            for (var i = 0; i <= 1000; i++)
            {
                var diff = FixMath.Sqrt(i).AsDouble - Math.Sqrt(i);

                maxDiff = Math.Max(maxDiff, Math.Abs(diff));
            }

            FixAssert.AssertEquals(maxDiff, 0, Epsilon);
        }
Example #3
0
        public void AtanAverageDeviationTest()
        {
            var totalDiff = 0.0;
            var maxDiff   = double.MinValue;

            for (var i = 0; i < 100; i++)
            {
                for (var j = 0; j < 100; j++)
                {
                    var diff = (double)FixMath.Atan2(i, j) - Math.Atan2(i, j);
                    totalDiff += diff;
                    maxDiff    = Math.Max(maxDiff, Math.Abs(diff));
                }
            }
            // Max & Average deviation
            FixAssert.AssertEquals(maxDiff, 0, 0.012f);
            FixAssert.AssertEquals(totalDiff / 360, 0, 0.008f);
        }
Example #4
0
        public void AsinAverageDeviationTest()
        {
            var totalDiff = 0.0;
            var maxDiff   = double.MinValue;

            for (var i = 0; i < 1000; i++)
            {
                var fixValue    = Fix.Ratio(i, 1000);
                var doubleValue = i / 1000.0;

                var diff = Math.Abs((double)FixMath.Asin(fixValue) - Math.Asin(doubleValue));
                totalDiff += diff;
                maxDiff    = Math.Max(maxDiff, Math.Abs(diff));
            }
            // Max & Average deviation
            FixAssert.AssertEquals(maxDiff, 0, 0.005f);
            FixAssert.AssertEquals(totalDiff / 360, 0, 0.002f);
        }
Example #5
0
        public void SinAverageDeviationTest()
        {
            var totalDiff = 0.0;
            var maxDiff   = double.MinValue;

            for (var i = 0; i < 3600; i++)
            {
                var fixAngle    = FixMath.Pi * i / 1800;
                var doubleAngle = Math.PI * i / 1800.0;

                var diff = Math.Abs((double)FixMath.Sin(fixAngle) - Math.Sin(doubleAngle));
                totalDiff += diff;
                maxDiff    = Math.Max(maxDiff, Math.Abs(diff));
            }
            // Max & Average deviation
            FixAssert.AssertEquals(maxDiff, 0, 0.019f);
            FixAssert.AssertEquals(totalDiff / 360, 0, 0.07f);
        }
        public void CreateDecimalTest()
        {
            var fix = Fix.CreateDecimal(1, 12, 2);

            FixAssert.AssertEquals(fix, 1.12f, Epsilon);
        }
        public void RatioTest()
        {
            var fix = Fix.Ratio(1, 2);

            FixAssert.AssertEquals(fix, 0.5f, Epsilon);
        }
        public void FixVec2MagnitudeTest()
        {
            var fixVec2 = new FixVec2(2, 1);

            FixAssert.AssertEquals(fixVec2.Magnitude, (float)Math.Sqrt(2 * 2 + 1 * 1), Epsilon);
        }