文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>NativeXml (11):浮点数的有效位数

NativeXml (11):浮点数的有效位数

时间:2011-03-25  来源:万一


uses NativeXml; 
 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  xml: TNativeXml; 
  fVal: Double; 
begin 
  fVal := 123.456789; 
 
  xml := TNativeXml.CreateName('List'); 
  xml.XmlFormat := xfReadable; 
 
  //xml.FloatSignificantDigits := ; 
  with xml.Root.NodeNew('item') do begin 
    WriteString('Name', 'AAA'); 
    WriteFloat('Weight', fVal); 
  end; 
 
  xml.FloatSignificantDigits := 5; 
  with xml.Root.NodeNew('item') do begin 
    WriteString('Name', 'BBB'); 
    WriteFloat('Weight', fVal); 
  end; 
 
  xml.FloatSignificantDigits := 1; 
  with xml.Root.NodeNew('item') do begin 
    WriteString('Name', 'CCC'); 
    WriteFloat('Weight', fVal); 
  end; 
 
  xml.FloatSignificantDigits := 9; 
  with xml.Root.NodeNew('item') do begin 
    WriteString('Name', 'DDD'); 
    WriteFloat('Weight', fVal); 
  end; 
 
  ShowMessage(xml.Root[0][1].Value); //123.457 
  ShowMessage(xml.Root[1][1].Value); //123.46 
  ShowMessage(xml.Root[2][1].Value); //100 
  ShowMessage(xml.Root[3][1].Value); //123.456789 
  Memo1.Text := xml.WriteToString; 
  xml.Free; 
end; 
{*************************************** 
<?xml version="1.0" encoding="UTF-8"?> 
<List> 
        <item> 
                <Name>AAA</Name> 
                <Weight>123.457</Weight> 
        </item> 
        <item> 
                <Name>BBB</Name> 
                <Weight>123.46</Weight> 
        </item> 
        <item> 
                <Name>CCC</Name> 
                <Weight>100</Weight> 
        </item> 
        <item> 
                <Name>DDD</Name> 
                <Weight>123.456789</Weight> 
        </item> 
</List> 
*****************************************}
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载