lucky_star
9 years agoOccasional Contributor
How to format Numeric using 1000 Separator ","
Hi,
Please help me to format the numeric which is used 1000 Separator ","
value1= "2,400";
value2 = "1";
value = aqConvert["VarToFloat"](value1) + aqConvert["VarToFloat"](value2);
>> the result value is "2401"
Expected that the value is format is "2,401"
Thanks for your helping
Interesting. I could only manage to print numbers with thousand separators using the deprecated functions:
// JScript function thousand() { var aaa = 1234.1; Log.Message(Utilities.FormatFloat("#.#,", aaa)); // 1,234.1 Log.Message(Utilities.FormatFloat("#.#", aaa)); // 1234.1 Utilities.ThousandSeparator = ";"; Log.Message(Utilities.FormatFloat("#.#,", aaa)); // 1;234.1 Log.Message(Utilities.FormatFloat("#.#", aaa)); // 1234.1 }
lucky_star wrote:
In this case, I expect that the result is format result as "1,234.10" , but the result is returned "1,234.1"
So how can I format decimal places = 2 ?
Log.Message(Utilities.FormatFloat("#.00,", 1234.1)); // 1,234.10
should do the trick.
Or if you would like to avoid using the deprecated Utilities functions, try this:
var number = 1234.1;
var str = dotNET.System.String.Format("{0:n2}", number).OleValue; // 1,234.10