Hello,
I have a tag of data type FLOAT. I want to convert the tag value to a string with two decimal places of precision. For example, value 10.12345678 would be converted to "10.12". This is what I am using:
String s = String.Format("{0:0.00}", Globals.Tags.DischargeRate.Value);
However, s does does not become "10.12", instead it becomes "10.123456". I have also tried:
String s = String.Format("F3", Globals.Tags.DischargeRate.Value);
with the same result. How to accomplish this? I am using A12 and iX 2.0;
String Format Specifier
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: String Format Specifier
Standard Numeric Format Strings.
Code: Select all
void Button1_Click(System.Object sender, System.EventArgs e)
{
Globals.Tags.Tag1.Value = 12.12344;
String s = Globals.Tags.Tag1.Value.Double.ToString("F2");
this.Text1.Text = s;
}
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Re: String Format Specifier
Working great now, thanks