Как в лейбл вывести числа double
Мне нужно выводить числа типа double полностью они приходят уже в формате String^
System::Void MyForm::button3_Click(System::Object^ sender, System::EventArgs^ e)
{
label1->Text = equals(conv(System::Convert::ToString(label2->Text)), conv(System::Convert::ToString(label1->Text)));
}
Если бы допустим я это выводил в консоль, то воспользовался бы cout << setprecision(5) << a;
Вот представляю функции, чтобы было более понятно
std::string MyForm::conv(String^ str)
{
std::string s;
s = msclr::interop::marshal_as<std::string>(str);
return s;
}
String^ MyForm::equals(std::string str1, std::string str2)
{
if (str1 == "")
return "DUMB";
if (str1 == "DUMB")
return "DUMB";
std::stringstream ss;
std::string str;
String^ str3;
double first;
double second;
double result;
char* arr = new char[str1.length()];
char* arr1 = new char[str2.length()];
char sym;
strcpy(arr, str1.c_str());
strcpy(arr1, str2.c_str());
sym = arr[str1.length() - 1];
for (int a = 0; a < str1.length()-1; a++)
{
if (arr[a] == ',')
ss << '.';
else
ss << arr[a];
}
ss >> first;
ss.clear();
for (int a = 0; a < str2.length(); a++)
{
if (arr1[a] == ',')
ss << '.';
else
ss << arr1[a];
}
ss >> second;
ss.clear();
switch (sym)
{
case '+' :
result = first + second;
break;
case '-':
result = first - second;
break;
case 'x':
result = first * second;
break;
case '/':
result = first / second;
break;
}
ss << result;
ss >> str;
ss.clear();
str3 = gcnew System::String(str.c_str());
str = "";
return str3;
}