DecimalSeparator
double
#include <SysUtils.hpp>
System::String FormatWithDot(double value)
{
System::Char old = Sysutils::DecimalSeparator;
Sysutils::DecimalSeparator = _D('.');
System::String s = Sysutils::FloatToStr(value);
Sysutils::DecimalSeparator = old;
return s;
}
System::String s = FormatWithDot(123.45);
TFormatSettings::DecimalSeparator
#include <SysUtils.hpp>
System::String FormatWithDot(double value)
{
Sysutils::TFormatSettings fmt = Sysutils::TFormatSettings::Create();
fmt.DecimalSeparator = _D('.');
return Sysutils::FloatToStr(value, fmt);
}
System::String s = FormatWithDot(123.45);
:
DecimalSeparator
请注意,
FloatToStr()
仅适用于基于Delphi的RTL函数,例如Format()
,std::(s)printf()
等。 等。对于那些,您需要使用C ++的语言。我本人在早上的凌晨解决了。您可以使用:
std::to_string()
然后格式化这样的两倍:
std::ostream::operator<<
我希望它对某人有帮助。我疯了。
我知道这是一个非常古老的线程,但是我今天面临着这个问题。就我而言,我的解决方案是:TFormatSettings fmt = TFormatSettings::Create();
fmt.DecimalSeparator = '.';
它等同于我用另一种语言所拥有的另一种。对我来说,这是有用的,因为数字是数字参数。
为C ++构建器12.2.
FloatToStr(price, fmt);