1. Technology

Your suggestion is on its way!

An email with a link to:

http://delphi.about.com/library/rtl/blrtlFloatToStrF.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
 

FloatToStrF

unit
SysUtils
category
Floating point conversion routines

declaration
function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer): string; overload;
function FloatToStrF(Value: Extended; Format: TFloatFormat; Precision, Digits: Integer; const FormatSettings: TFormatSettings): string; overload;

description
Returns a string from a floating point value, using a specified Format, Precision, and Digits.

FloatToStrF converts the given floating-point value to its string representation. The conversion uses Precision and Digits parameters to control how the value is formatted into a string. Details are specified using the TFloatFormat parameter.

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

example
var PI1000 : extended;

PI1000 := PI * 1000; // 3141592.6535897932385

FloatToStrF(pi1000,ffGeneral,12,2); 
// '3141.59265359'

FloatToStrF(pi1000,ffExponent,12,2);
// '3.14159265359E+03'

FloatToStrF(pi1000,ffFixed,12,2);
// '3141.59'

FloatToStrF(pi1000,ffNumber,12,2);
// '3,141.59'

FloatToStrF(pi1000,ffCurrency,12,2);
// '3,141.59 kn' (kn is currency symbol in Croatia)

in real code

see also
TFloatFormat, 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.