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()); }
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)); }
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()); }
public string ToString(string format, IFormatProvider formatProvider) { return(toString(Re.ToString(format, formatProvider), Im.ToString(format, formatProvider))); }
public string ToString(string format) { return(toString(Re.ToString(format), Im.ToString(format))); }
public override string ToString() { return(toString(Re.ToString(), Im.ToString())); }
public string ToString(string format, System.IFormatProvider formatProvider) { return(Re.ToString(format, formatProvider) + (Im < 0 ? @" " : @" +") + Im.ToString(format, formatProvider) + @"*i"); }
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"); }
public string ToString(string format, System.IFormatProvider formatProvider) { return(Re.ToString(format, formatProvider) + (Im < 0 ? " " : " +") + Im.ToString(format, formatProvider) + 'i'); }