[Overview][Constants][Types][Classes][Procedures and functions][Variables] | Reference for unit 'sysutils' (#rtl) |
Convert a string to a floating-point value.
Source position: line 0
function StrToFloat( |
const S: String |
):Extended; |
const S: String; |
const FormatSettings: TFormatSettings |
):Extended; |
StrToFloat converts the string S to a floating point value. S should contain a valid stroing representation of a floating point value (either in decimal or scientific notation). If the string contains a decimal value, then the decimal separator character can either be a '.' or the value of the DecimalSeparator variable.
If the string S doesn't contain a valid floating point string, then an exception will be raised.
|
Convert a buffer to a float value. |
|
|
Convert a float value to a string using a fixed format. |
|
|
Format a float according to a certain mask. |
|
|
Convert a string to an integer value. |
Program Example90; { This program demonstrates the StrToFloat function } {$mode objfpc} {$h+ } Uses SysUtils; Const NrValues = 5; TestStr : Array[1..NrValues] of string = ('1,1','-0,2','1,2E-4','0','1E4'); Procedure Testit; Var I : Integer; E : Extended; begin Writeln('Using DecimalSeparator : ',DecimalSeparator); For I:=1 to NrValues do begin Writeln('Converting : ',TestStr[i]); Try E:=StrToFloat(TestStr[i]); Writeln('Converted value : ',E); except On E : Exception do Writeln('Exception when converting : ',E.Message); end; end; end; Begin DecimalSeparator:=','; Testit; DecimalSeparator:='.'; Testit; End.
No notes exist for this page yet.