Example #1
0
        /// <summary cref="XMath.IEEERemainder(float, float)"/>
        public static float IEEERemainder(float x, float y)
        {
            if (y == 0.0f ||
                XMath.IsInfinity(x) ||
                XMath.IsNaN(x) ||
                XMath.IsNaN(y))
            {
                return(float.NaN);
            }

            if (XMath.IsInfinity(y))
            {
                return(x);
            }

            return(x - (y * XMath.RoundToEven(x * XMath.Rcp(y))));
        }
Example #2
0
        public static double IEEERemainder(double x, double y)
        {
            if (y == 0.0 ||
                XMath.IsInfinity(x) ||
                XMath.IsNaN(x) ||
                XMath.IsNaN(y))
            {
                return(double.NaN);
            }

            if (XMath.IsInfinity(y))
            {
                return(x);
            }

            return(x - (y * XMath.RoundToEven(x * XMath.Rcp(y))));
        }