Home     Projects     Micro     Tools     Delphi     Developer     Site map
HOME  
 
Delphi index
 
How to display floating point

To display floating point .First, we must converts a floating point value to a string by the function

function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): string;

Description

The Value parameter is the value to convert.

Format is a format after converts Value

The Precision 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 Digits 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,ffFixed,16,2));

Result Volt = 12. 35


Volt := 12.3456;
showmessage('Volt = '+FloatToStrF(Volt,ffFixed,16,6));

Result Volt = 12. 345600

Volt := 12.123456789123456789;
showmessage('Volt = '+FloatToStrF(Volt,ffExponent ,16,2));

Result Volt = 1.212345678912346E+01


 
Copyright(c) 2005-2008 sixca.com, All right reserved.
Best view @ 800X600, IE 6.0 up   
Terms of Use  Privacy Policy