How to display floating point
To display floating point .First, we must converts a floating point value to a string by the function
FloatToStrF(: Extended; : TFloatFormat; , : Integer): string;
Description The parameter is the value to convert.
is a format after converts Value
The parameter specifies the precision of the given value. It should be 7 or less for values of type Single, 15 or less for values of type Double, and 18 or less for values of type Extended.
The and Format parameters together control how the value is formatted into a string. For details, see the description of TFloatFormat.
Example
:
Volt := 12.3456;
showmessage('Volt = '+FloatToStrF(Volt,,16,2));
Result
Volt = 12. 35
Volt := 12.3456;
showmessage('Volt = '+FloatToStrF(Volt,,16,6));
Result Volt = 12. 345600
Volt := 12.123456789123456789;
showmessage('Volt = '+FloatToStrF(Volt, ,16,2));
Result Volt = 1.212345678912346E+01
|