コード例 #1
0
ファイル: ImTest.cs プロジェクト: sys27/xFunc
        public void ToStringTest()
        {
            var complex = new Complex(3.1, 2.5);
            var exp = new Im(new ComplexNumber(complex));

            Assert.Equal("im(3.1+2.5i)", exp.ToString());
        }
コード例 #2
0
        public void ImToStringTest()
        {
            var complex = new Complex(3.1, 2.5);
            var exp     = new Im(new ComplexNumber(complex));

            Assert.Equal("im(3.1+2.5i)", exp.ToString(commoonFormatter));
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            // povikuvanje na site broevi pomali od 0
            const double small = 1E-15;
            double       Re;
            double       Im;

            //presmetka na koren
            List <Complex> Roots = SolveCubic(Coeff.A, Coeff.B, Coeff.C, Coeff.D);

            Re             = Math.Abs(Roots[0].Real) < small ? 0.0 : Roots[0].Real;
            Im             = Math.Abs(Roots[0].Imaginary) < small ? 0.0 : Roots[0].Imaginary;
            X1RealTxb.Text = Re.ToString();
            X1ImagTxb.Text = Im.ToString();

            Re             = Math.Abs(Roots[1].Real) < small ? 0.0 : Roots[1].Real;
            Im             = Math.Abs(Roots[1].Imaginary) < small ? 0.0 : Roots[1].Imaginary;
            X2RealTxb.Text = Re.ToString();
            X2ImagTxb.Text = Im.ToString();

            Re             = Math.Abs(Roots[2].Real) < small ? 0.0 : Roots[2].Real;
            Im             = Math.Abs(Roots[2].Imaginary) < small ? 0.0 : Roots[2].Imaginary;
            X3RealTxb.Text = Re.ToString();
            X3ImagTxb.Text = Im.ToString();
        }
コード例 #4
0
        public override string ToString()
        {
            string result = Re.ToString();

            if (Im < 0)
            {
                result += (Im.ToString() + "i");
            }
            else
            {
                result += ("+" + Im.ToString() + "i");
            }
            return(result);
        }
コード例 #5
0
 public override int GetHashCode()
 {
     return(Re.ToString().GetHashCode() ^ Im.ToString().GetHashCode());
 }
コード例 #6
0
 public string ToString(string format, IFormatProvider formatProvider)
 {
     return(toString(Re.ToString(format, formatProvider), Im.ToString(format, formatProvider)));
 }
コード例 #7
0
 public string ToString(string format)
 {
     return(toString(Re.ToString(format), Im.ToString(format)));
 }
コード例 #8
0
 public override string ToString()
 {
     return(toString(Re.ToString(), Im.ToString()));
 }
コード例 #9
0
 public string ToString(string format, System.IFormatProvider formatProvider)
 {
     return(Re.ToString(format, formatProvider) + (Im < 0 ? @" " : @" +") + Im.ToString(format, formatProvider) + @"*i");
 }
コード例 #10
0
 public string ToString(string format)
 {
     return(Re.ToString(format) + (Im < 0 ? @" " : @" +") + Im.ToString(format) + @"*i");
 }
 //ComplexNumberString(): Karmaşık sayı hakkında metinsel bilgi döndürür.
 public string ComplexNumberString()
 {
     return("(" + Re.ToString() + ")" + "+" + "(" + Im.ToString() + ")" + "i");
 }
コード例 #12
0
 public string ToString(string format, System.IFormatProvider formatProvider)
 {
     return(Re.ToString(format, formatProvider) + (Im < 0 ? " " : " +") + Im.ToString(format, formatProvider) + 'i');
 }