函数 FloatToDecimal 的使用方法(100分)

  • 主题发起人 主题发起人 tansh
  • 开始时间 开始时间
T

tansh

Unregistered / Unconfirmed
GUEST, unregistred user!
请问FloatToDecimal函数的使用方法!
请给例子!!!![:(][:(]
 
有这个函数吗?
 
好像没看到过,也许有!
 
Converts a floating-point value to a decimal representation.
Unit
SysUtils
Category
floating point conversion routines
procedure FloatToDecimal(var DecVal: TFloatRec;
const Value;
ValueType: TFloatValue;
Precision, Decimals: Integer);
Description
FloatToDecimal converts a floating-point value to a decimal representation that is suited for further formatting.
The Value parameter must be a variable of type Extended or Currency, as indicated by the ValueType parameter.
For values of type Extended, the Precision parameter specifies the requested number of significant digits in the result--the allowed range is 1..18. For values of type Currency, the Precision parameter is ignored, and the implied precision of the conversion is 19 digits.
The Decimals parameter specifies the requested maximum number of digits to the left of the decimal point in the result. Precision and Decimals together control how the result is rounded. To produce a result that always has a given number of significant digits regardless of the magnitude of the number, specify 9999 for the Decimals parameter.
 
procedure TForm1.Button1Click(Sender: TObject);
var
f:TFloatRec;
x:extended;
s:string;
begin
x:=-10.1234;
FloatToDecimal(f,x,fvExtended,5,2);
s:='';
if f.Negative then
s:='-';
s:=s+'0.'+f.Digits;
if f.Exponent<>0 then
s:=s+' X 10^'+inttostr(f.Exponent);
showmessage(s);
end;
 
后退
顶部