使用floattostr转换时,浮点数首先变成extended类型,转换为字符串后多出一些小数.
0.1234变成'0.1234117178'.
如何使字符串等于'0.1234'??????
不要说用format,要能够自动判断小数位数.

解决方案 »

  1.   

    原型:
    function FormatFloat(const Format: string; Value: Extended): string; overload;
    function FormatFloat(const Format: string; Value: Extended; const FormatSettings: TFormatSettings): string; overload;
    The following table shows some sample formats and the results produced when the formats are applied to different values:
    Format string- 1234 -1234 0.5 0
    1234 -1234 0.5 0
    0 1234 -1234 1 0
    0.00  1234.00 -1234.00 0.50 0.00
    #.##   1234 -1234 .5
    #,##0.00 1,234.00 -1,234.00 0.50 0.00
    #,##0.00;(#,##0.00) 1,234.00 (1,234.00) 0.50 0.00
    #,##0.00;;Zero  1,234.00 -1,234.00 0.50 Zero
    0.000E+00    1.234E+03 -1.234E+03 5.000E-01 0.000E+00
    #.###E-0   1.234E3 -1.234E3 5E-1 0E0