public override void SetString(string str) { TComplex temp = new TComplex(str); Real = temp.Real; Imaginary = temp.Imaginary; }
private void Button_Complex_ShowAllRoots(object sender, EventArgs e) { ShowRoots RootsForm = new ShowRoots(); int RootN = Convert.ToInt32(nUD_Complex_Root_N.Value); TComplex number = new TComplex(tB_Complex.Text); for (int i = 0; i < RootN; ++i) { RootsForm.richTB_Roots.Text += "Root " + i.ToString() + ": " + number.Root(RootN, i).ToString() + Environment.NewLine; } RootsForm.ShowDialog(); }
public override object Reverse() { TComplex toReturn = new TComplex(Real / (Real * Real + Imaginary * Imaginary), -(Imaginary / (Real * Real + Imaginary * Imaginary))); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public override object Square() { TComplex toReturn = new TComplex(Real * Real - Imaginary * Imaginary, Real * Imaginary + Real * Imaginary); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public override TANumber Sub(TANumber a) { TComplex toReturn = new TComplex(Real - (a as TComplex).Real, Imaginary - (a as TComplex).Imaginary); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public override TANumber Div(TANumber a) { TComplex toReturn = new TComplex((Real * (a as TComplex).Real + Imaginary * (a as TComplex).Imaginary) / ((a as TComplex).Real * (a as TComplex).Real + (a as TComplex).Imaginary + (a as TComplex).Imaginary), ((a as TComplex).Real * Imaginary - Real * (a as TComplex).Imaginary) / ((a as TComplex).Real * (a as TComplex).Real + (a as TComplex).Imaginary * (a as TComplex).Imaginary)); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public static TComplex operator /(TComplex a, TComplex b) { TComplex toReturn = new TComplex((a.Real * b.Real + a.Imaginary * b.Imaginary) / (b.Real * b.Real + b.Imaginary + b.Imaginary), (b.Real * a.Imaginary - a.Real * b.Imaginary) / (b.Real * b.Real + b.Imaginary * b.Imaginary)); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
public static TComplex operator -(TComplex a, TComplex b) { TComplex toReturn = new TComplex(a.Real - b.Real, a.Imaginary - b.Imaginary); if (toReturn.Real.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } else if (toReturn.Imaginary.ToString().Length > OverflowStringLimit) { throw new OverflowException(); } return(toReturn); }
private void Button_Complex_Special(object sender, EventArgs e) { try { Button button = (Button)sender; Enum.TryParse(button.Tag.ToString().Replace(TAG_COMPLEX, string.Empty), out Complex_func ParsedEnum); TComplex number = new TComplex(tB_Complex.Text); switch (ParsedEnum) { case Complex_func.Pwr: int PwrN = Convert.ToInt32(nUD_Complex_Pwr.Value); tB_Complex_SpecialOut.Text = number.Pwr(PwrN).ToString(); break; case Complex_func.Root: int RootN = Convert.ToInt32(nUD_Complex_Root_N.Value); int Rooti = Convert.ToInt32(nUD_Complex_Root_i.Value); tB_Complex_SpecialOut.Text = number.Root(RootN, Rooti).ToString(); break; case Complex_func.Abs: tB_Complex_SpecialOut.Text = number.Abs().ToString(); break; case Complex_func.Dgr: tB_Complex_SpecialOut.Text = number.GetDegree().ToString(); break; case Complex_func.Rad: tB_Complex_SpecialOut.Text = number.GetRad().ToString(); break; } } catch { tB_Complex_SpecialOut.Text = "ERROR"; } }
private string Number_to_state(string tag, string str) { if ("ERROR" == str) { return(str); } string return_str = str; switch (tag) { case TAG_PNUMBER: break; case TAG_FRAC: if (true == frac_mode) { return_str = str; } else if (new TFrac(str).Denominator == 1) { return_str = new TFrac(str).Numerator.ToString(); } break; case TAG_COMPLEX: if (true == complex_mode) { return_str = str; } else if (new TComplex(str).Imaginary == 0) { return_str = new TComplex(str).Real.ToString(); } break; } return(return_str); }
private string NumberBeatifier(string Tag, string str) { if (str == "ERROR") { return(str); } string ToReturn = str; switch (Tag) { case TAG_PNUMBER: break; case TAG_FRAC: if (FracMode == true) { ToReturn = str; } else if (new TFrac(str).Denominator == 1) { ToReturn = new TFrac(str).Numerator.ToString(); } break; case TAG_COMPLEX: if (ComplexMode == true) { ToReturn = str; } else if (new TComplex(str).Imaginary == 0) { ToReturn = new TComplex(str).Real.ToString(); } break; } return(ToReturn); }
public TComplex(TComplex anotherComplex) { Real = anotherComplex.Real; Imaginary = anotherComplex.Imaginary; }