主题:数据库生成xml文件后,单价问题
各位老师,有的品种在数据库里,RUKUJIA原来是9.7,数据库生成xml文件后,在xml文件里,RUKUJIA却成了9.699999999999999,这种情况有好多,还有的是9.80000000000001.这是什么原因啊,困扰了好多天,下面是代码,请老师们帮我看看是什么原因造成的,谢谢!
***********************************************
use yaopin
rq=date()-1
hhh="d:\rkdyf\"+subs(dtoc(rq),1,4)+subs(dtoc(rq),6,2)+subs(dtoc(rq),9,2)+"期初库存.xml"
=cursortoxml("YaoPin",hhh)
function cursortoxml
parameters alias1,outputfile
local string1
select (alias1)
=afield(fa1)
length1=alen(fa1,1)
fhandle1=fcreate(outputfile)
=fput(fhandle1,'<?xml version="1.0" encoding="utf-8"?>')
=fput(fhandle1,"<Upload>")
scan
for i=iif(danjuhao=" ",4,1) to length1
string1="<"+fa1[i,1]+">"+alltrim(trans(eval(fa1[i,1])))+"</"+fa1[i,1]+">"
=fput(fhandle1,string1)
endfor
Endscan
=fput(fhandle1,chr(9)+"</RuKu>")
=fput(fhandle1,"</YaoPin>")
=fput(fhandle1,"</Upload>")
=fclose(fhandle1)
aaab=hhh
run/n notepad "&aaab"
***********************************************
use yaopin
rq=date()-1
hhh="d:\rkdyf\"+subs(dtoc(rq),1,4)+subs(dtoc(rq),6,2)+subs(dtoc(rq),9,2)+"期初库存.xml"
=cursortoxml("YaoPin",hhh)
function cursortoxml
parameters alias1,outputfile
local string1
select (alias1)
=afield(fa1)
length1=alen(fa1,1)
fhandle1=fcreate(outputfile)
=fput(fhandle1,'<?xml version="1.0" encoding="utf-8"?>')
=fput(fhandle1,"<Upload>")
scan
for i=iif(danjuhao=" ",4,1) to length1
string1="<"+fa1[i,1]+">"+alltrim(trans(eval(fa1[i,1])))+"</"+fa1[i,1]+">"
=fput(fhandle1,string1)
endfor
Endscan
=fput(fhandle1,chr(9)+"</RuKu>")
=fput(fhandle1,"</YaoPin>")
=fput(fhandle1,"</Upload>")
=fclose(fhandle1)
aaab=hhh
run/n notepad "&aaab"