예제 #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();
        }
        public override string ToString()
        {
            string result = Re.ToString();

            if (Im < 0)
            {
                result += (Im.ToString() + "i");
            }
            else
            {
                result += ("+" + Im.ToString() + "i");
            }
            return(result);
        }
 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');
 }