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
 

StrToFloat

unit
SysUtils
category
Floating point conversion routines

declaration
function StrToFloat(const S: string): Extended; overload;
function StrToFloat(const S: string; const FormatSettings: TFormatSettings): Extended; overload;

description
Returns a floating point value from a string

S must consist of an optional sign (+ or -), a string of digits with an optional decimal point (which must match the current DecimalSeparator valuue), and an optional mantissa. The mantissa consists of 'E' or 'e' followed by an optional sign (+ or -) and a whole number. Leading and trailing blanks are ignored.

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

example
var ex: extended;

ex := StrToFloat('3,141,592.6535'); 
//ex == 3141592.6535


ex := StrToFloat('1.05E+2'); 
//ex == 105

ex := StrToFloat('$FF'); //trying to convert a hex number
// Exception : EConvertError


in real code

see also
TFormatSettings, FloatToStrF, FormatFloat, 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.