且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

delphi xe5 StrToFloat故障将ThousandSeparator更改为“,”

更新时间:2023-12-02 10:30:16

您在这里所做的是正确的,但您偶然发现在Delphi SysUtils单元的TextToFloat(似乎忽略了ThousandSeparator)内部函数的错误(如果不是错误,至少不是非常不一致的行为)中(请参阅 Q92265 遵循决议)...

What you are doing here is correct, but you stumbled in what it seems a bug(if not a bug at least a not very consistent behaviour) of the TextToFloat(it seems that it ignores ThousandSeparator) internal function of Delphi SysUtils unit(take a look at the Q92265 to follow resolution ) ...

作为解决方法,您可以尝试通过以下方式删除组分隔符:

As a workaround you can try removing the group separator, in this way :

StringReplace('3,332.1', ',', '', [rfReplaceAll])