Exemple #1
0
        public DoubleExtension(double value)
        {
            if (DoubleUtil.IsCloseToZero(value))
            {
                _boxedValue = BoxedConstants.Double.Zero;
            }
            else if (DoubleUtil.IsCloseToOne(value))
            {
                _boxedValue = BoxedConstants.Double.One;
            }
            else if (value.IsNaN())
            {
                _boxedValue = BoxedConstants.Double.NaN;
            }

            _boxedValue = value;
        }
Exemple #2
0
        public static double RoundLayoutValue(double value, double scale)
        {
            if (DoubleUtil.IsCloseToOne(scale))
            {
                return(Math.Round(value));
            }

            const long EncodingOfDoubleMaxValue = 0x7FEFFFFFFFFFFFFFL;

            var result = Math.Round(value * scale) / scale;

            if ((BitConverter.DoubleToInt64Bits(result) & long.MaxValue) < EncodingOfDoubleMaxValue)
            {
                return(result);
            }

            return(value);
        }
 private static bool IsThetaMultipleOf45Degrees(double theta) =>
 (IsThetaMultipleOf90Degress(theta) || DoubleUtil.IsCloseToOne(Math.Abs(Math.Tan(theta))));