// DecimalFormat is a little disappointing coming from Fortran or C's printf. // Since it doesn't pad on the left, the elements will come out different // widths. Consequently, we'll pass the desired column width in as an // argument and do the extra padding ourselves. /// <summary> Print the matrix to the output stream. Line the elements up in columns. /// Use the format object, and right justify within columns of width /// characters. /// Note that is the matrix is to be read back in, you probably will want /// to use a NumberFormat that is set to US Locale. /// </summary> /// <param name="output">the output stream. /// </param> /// <param name="format">A formatting object to format the matrix elements /// </param> /// <param name="width"> Column width. /// </param> /// <seealso cref="java.text.DecimalFormat.setDecimalFormatSymbols"> /// </seealso> public virtual void print(System.IO.StreamWriter output, TextNumberFormat format, int width) { //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'" output.WriteLine(); // start on new line. for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { System.String s = format.FormatDouble(A[i][j]); // format the number int padding = System.Math.Max(1, width - s.Length); // At _least_ 1 space for (int k = 0; k < padding; k++) output.Write(' '); output.Write(s); } //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'" output.WriteLine(); } //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln'" output.WriteLine(); // end with blank line. }
/// <summary> Print the matrix to the output stream. Line the elements up in /// columns with a Fortran-like 'Fw.d' style format. /// </summary> /// <param name="output">Output stream. /// </param> /// <param name="w"> Column width. /// </param> /// <param name="d"> Number of digits after the decimal. /// </param> public virtual void print(System.IO.StreamWriter output, int w, int d) { //UPGRADE_ISSUE: Class 'java.text.DecimalFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextDecimalFormat'" //UPGRADE_ISSUE: Constructor 'java.text.DecimalFormat.DecimalFormat' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextDecimalFormat'" //DecimalFormat format = new DecimalFormat(); //UPGRADE_ISSUE: Method 'java.text.DecimalFormat.setDecimalFormatSymbols' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextDecimalFormat'" //format.setDecimalFormatSymbols(new System.Globalization.CultureInfo("en-US").NumberFormat); //UPGRADE_ISSUE: Method 'java.text.DecimalFormat.setMinimumIntegerDigits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextDecimalFormat'" //format.setMinimumIntegerDigits(1); //UPGRADE_ISSUE: Method 'java.text.DecimalFormat.setMaximumFractionDigits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextDecimalFormat'" //format.setMaximumFractionDigits(d); //UPGRADE_ISSUE: Method 'java.text.DecimalFormat.setMinimumFractionDigits' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javatextDecimalFormat'" //format.setMinimumFractionDigits(d); //format.GroupingUsed = false; TextNumberFormat format = new TextNumberFormat(); format.Digits = d; format.GroupingUsed = false; print(output, format, w + 2); }
/// <summary> Print the matrix to stdout. Line the elements up in columns. /// Use the format object, and right justify within columns of width /// characters. /// Note that is the matrix is to be read back in, you probably will want /// to use a NumberFormat that is set to US Locale. /// </summary> /// <param name="format">A Formatting object for individual elements. /// </param> /// <param name="width"> Field width for each column. /// </param> /// <seealso cref="java.text.DecimalFormat.setDecimalFormatSymbols"> /// </seealso> public virtual void print(TextNumberFormat format, int width) { System.IO.StreamWriter temp_writer; temp_writer = new System.IO.StreamWriter(System.Console.OpenStandardOutput(), System.Text.Encoding.Default); temp_writer.AutoFlush = true; print(temp_writer, format, width); }
public static TextNumberFormat GetTextNumberPercentInstance(CultureInfo culture) { TextNumberFormat instance = new TextNumberFormat(formatTypes.Percent, culture, 3); return instance; }
public static TextNumberFormat GetTextNumberCurrencyInstance(CultureInfo culture) { TextNumberFormat instance = new TextNumberFormat(formatTypes.Currency, culture, 3); return instance; }
public static TextNumberFormat GetTextNumberPercentInstance() { TextNumberFormat instance = new TextNumberFormat(formatTypes.Percent, 3); return instance; }
public static TextNumberFormat GetTextNumberCurrencyInstance() { TextNumberFormat instance = new TextNumberFormat(formatTypes.Currency, 3); return instance; }
public static TextNumberFormat GetTextNumberInstance() { TextNumberFormat instance = new TextNumberFormat(formatTypes.Number, 3); return instance; }