1. Home
  2. Computing & Technology
  3. Delphi Programming
Glossary|Tips/Tricks|FREE App/VCL|Best'O'Net|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

FormatFloat

unit
SysUtils
category
Floating point conversion routines

declaration
function FormatFloat(const Format: string; Value: Extended): string; overload;
function FormatFloat(const Format: string; Value: Extended; const FormatSettings: TFormatSettings): string; overload;

description
Returns a string from a floating point value using the provided format string.

The second form of FormatFloat, refers to localization information contained in the FormatSettings parameter.

Format specifiers supported in the format string are:

  • 0 Digit place holder.
  • # Digit placeholder.
  • . Decimal point.
  • , Thousand separator.
  • E+ Scientific notation.
  • 'xx'/"xx" Characters enclosed in single or double quotes are output as-is.
  • ; Separates sections for positive, negative, and zero numbers in the format string.

    example
    const AValue = 98765432.1;
    
    FormatFloat('0',AValue);
    // '98765432'
    
    FormatFloat('###,###,###.0000',AValue);
    // '98.765.432,1000'
    
    FormatFloat('"Number" #.00',AValue);
    // 'Number 98765432,10'
    
    FormatFloat(',.00',AValue);
    // '98.765.432,10'
    

    in real code

    see also
    TFormatSettings, FloatToStrF, FloatToStr,


     Free Delphi code snippet inside every Delphi Newsletter!
    Subscribe to the Newsletter
    Name
    Email

     Got some code to share? Got a question? Need some help?
  • Explore Delphi Programming
    About.com Special Features

    Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

    Easy ways to connect two computers for networking purposes. More >

    1. Home
    2. Computing & Technology
    3. Delphi Programming

    ©2009 About.com, a part of The New York Times Company.

    All rights reserved.