1. Technology

Your suggestion is on its way!

An email with a link to:

http://delphi.about.com/library/rtl/blrtlFormatFloat.htm

was emailed to:

Thanks for sharing About.com with others!

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?
  • ©2014 About.com. All rights reserved.