B benxiong Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-23 #1 请问各位年兄:如何将浮点数按指定位有效数字格式输出? 如按4位有效数字输出的话,则将数字36.1转换成字符串'36.10';将数字136.15转换成字符串'136.2'
Y yostgxf Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-23 #2 用FloatToStrF 函数 还有Round,Trunc等 function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): string;
用FloatToStrF 函数 还有Round,Trunc等 function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): string;
陈 陈健松 Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-24 #3 memo1.Lines.Add(FormatFloat('0.00',36.1)); memo1.Lines.Add(FormatFLoat('#.#', 136.15));
Y yu_ting Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-24 #5 ForamtFloat('0.00', aFloatNumber)
B benxiong Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-25 #6 具体的数值事先未知,由用户输入,然后按即定的有效数字输出。
H hnxx2003 Unregistered / Unconfirmed GUEST, unregistred user! 2004-02-27 #8 var a:double; s:string; begin a:=13.245; s:=floattostr(a); s:=copy(s,1,4); a:=strtofloat(s); end;