public override string ToString() { if (Variables.Count == 0) { return(Coefficient.ToString()); } StringBuilder sb = new StringBuilder(); if (Coefficient != 1) { if (Coefficient == -1) { sb.Append('-'); } else { sb.Append(Coefficient); } } foreach (var variable in Variables) { sb.Append(variable.ToString()); } return(sb.ToString()); }
public override XElement ToXElement() { XElement xe = new XElement(XElementName()); xe.Add(new XAttribute("Name", Name)); xe.Add(new XAttribute("Type", EntityType.ToString())); xe.Add(new XAttribute("P", Alignment.ToString())); xe.Add(new XAttribute("Size", BufferSize.ToString())); xe.Add(new XAttribute("Coeffi", Coefficient.ToString())); xe.Add(this.GetPropertiesXElement()); return(xe); }
public override XElement ToXElement() { XElement xe = new XElement("Spot"); xe.Add(new XAttribute("Name", Name)); xe.Add(new XAttribute("Type", EntityType.ToString())); xe.Add(new XAttribute("Pos", Position.ToString())); xe.Add(new XAttribute("Rad", ServingRadius.ToString())); xe.Add(new XAttribute("Coeffi", Coefficient.ToString())); xe.Add(this.GetPropertiesXElement()); return(xe); }
public override string ToString() { var result = new List <string>(); if (!Coefficient.Equals(NumberDecimal.One)) { result.Add(Coefficient.ToString()); } result.AddRange(Variables.Select(a => a.ToString())); result.AddRange(Others.Select(a => "(" + a.ToString() + ")")); return(string.Join("*", result)); }
public override string ToString() { var builder = new StringBuilder(); builder.Append(Coefficient.ToString()); foreach (var unknown in UnKnowns) { builder.Append(unknown.ToString()); } return(builder.ToString()); }
public List <Run> DisplayText() { List <Run> display = new List <Run>(); if (Coefficient > 1) { display.Add(new Run() { Text = Coefficient.ToString() }); } foreach (MoleculeItem mi in Items) { display.AddRange(mi.DisplayText()); } return(display); }
/// <summary> /// S = simplest form, R = all under the radical /// </summary> /// <param name="format"></param> /// <param name="formatProvider"></param> /// <returns></returns> public string ToString(string format, IFormatProvider formatProvider) { if (Coefficient.IsZero) { return("0"); } if (Radicand.IsZero) { return("0"); } if (format == null) { format = "S"; } if (IsZero) { return(0.ToString()); } if (IsOne) { return(1.ToString()); } var result = new StringBuilder(); // Simplest form if ("S".Equals(format)) { // Handle coefficient // TODO: Pass format through if (Coefficient.Denominator.IsOne) { if (!Coefficient.Numerator.IsOne || (Coefficient.Numerator.IsOne && Radicand.IsOne)) { if (Sign < 0) { result.Append("(" + Coefficient.Numerator.ToString() + ")"); } else { result.Append(Coefficient.Numerator.ToString()); } } } else { result.Append("(" + Coefficient.ToString() + ")"); } // Handle radicand if (Index > 1 && Radicand > 1) { if (result.Length > 0) { result.Append("*"); } if (Index == 2) { result.Append("Sqrt"); } else { result.Append("Nth-Root[index:" + Index.ToString() + "]"); } result.Append("(" + Radicand.ToString() + ")"); } } else if ("R".Equals(format)) { if (Index == 1) { if (Coefficient.Denominator.IsOne) { if (!Coefficient.Numerator.IsOne || (Coefficient.Numerator.IsOne && Radicand.IsOne)) { result.Append(Coefficient.Numerator.ToString()); } } else { result.Append("(" + Coefficient.ToString() + ")"); } } else { if (Sign < 0) { result.Append("-"); } // Get the rational for all under the radical if (Index == 2) { result.Append("Sqrt"); } else { result.Append("Nth-Root[index:" + Index.ToString() + "]"); } var radicand = RaisedToIndexPower; if (radicand.Denominator.IsOne) { result.Append("(" + BigInteger.Abs(radicand.Numerator).ToString() + ")"); } else { result.Append("(" + Rational.Abs(radicand.CanonicalForm).ToString() + ")"); } } } return(result.ToString()); }
public override string ToString() { var variables = Variables.Count > 0 ? Variables.Select(kvp => kvp.Key + "^" + kvp.Value).Aggregate((s1, s2) => s1 + s2) : ""; return(Coefficient.ToString() + variables); }
public override string ToString() { return((Coefficient > 1 ? Coefficient.ToString() : "") + string.Join("", Elements)); }