Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SignedRational"/> struct.
        /// </summary>
        /// <param name="value">The <see cref="double"/> to create the instance from.</param>
        /// <param name="bestPrecision">Whether to use the best possible precision when parsing the value.</param>
        public SignedRational(double value, bool bestPrecision)
        {
            var rational = LongRational.FromDouble(value, bestPrecision);

            this.Numerator   = (int)rational.Numerator;
            this.Denominator = (int)rational.Denominator;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rational"/> struct.
        /// </summary>
        /// <param name="value">The <see cref="double"/> to create the instance from.</param>
        /// <param name="bestPrecision">Whether to use the best possible precision when parsing the value.</param>
        public Rational(double value, bool bestPrecision)
        {
            var rational = LongRational.FromDouble(Math.Abs(value), bestPrecision);

            this.Numerator   = (uint)rational.Numerator;
            this.Denominator = (uint)rational.Denominator;
        }