From Clomosy Docs

(Created page with " function StrToFloat(FloatString string):Extended; The StrToFloat function converts a number string, FloatString such as '123,456' into an Extended floating point number. It supports integer, floating point, and scientific (exponent) formats. If a decimal point appears in FloatString, then it must match the current DecimalSeparator value.<br> '''Example:'''<br> '''var''' stringValue : string; floatValue : float;<br> '''begin'''<br> // Set up the source st...")
 
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
function StrToFloat(FloatString string):Extended;
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert">
function StrToFloat(const S: string):Extended;
</div>


The StrToFloat function converts a number string, FloatString such as '123,456' into an Extended floating point number. It supports integer, floating point, and scientific (exponent) formats.
The StrToFloat function converts a number string, FloatString such as '123,456' into an Extended floating point number. It supports integer, floating point, and scientific (exponent) formats.<br>
 
If a decimal point appears in FloatString, then it must match the current DecimalSeparator value.<br>
<b>Example</b><br>


'''Example:'''<br>
<pre>
  '''var'''
  var
   stringValue : string;
   stringValue : string;
   floatValue  : float;<br>
   floatValue  : float;
  '''begin'''<br>
   
{
   // Set up the source string containing a number representation
   // Set up the source string containing a number representation
   stringValue := '123,456';<br>
   stringValue = '123,456';
   // Convert it to a floating point number
   // Convert it to a floating point number
   floatValue  := StrToFloat(stringValue);<br>
   floatValue  = StrToFloat(stringValue);
   // And display the value
   // And display the value
   ShowMessage(stringValue+' = '+FloatToStr(floatValue));<br>
   ShowMessage(stringValue+' = '+FloatToStr(floatValue));
'''end;'''
}
</pre>
 
<b>Output:</b><br>
<div class="alert alert-success" role="alert" data-bs-theme="light">
123,456 = 123,456
</div>


'''Output:'''<br>
<h2> See Also </h2>
123,456 = 123,456
* [[System_Library#Type_Conversion_Functions | Type Conversion Functions]]
{{#seo:|title=StrToFloat Using in Clomosy - Clomosy Docs}}
{{#seo:|description=Use StrToFloat in Clomosy to convert a number string into a floating-point value, supporting various formats.}}

Latest revision as of 14:22, 24 December 2024

The StrToFloat function converts a number string, FloatString such as '123,456' into an Extended floating point number. It supports integer, floating point, and scientific (exponent) formats.

Example

 var
   stringValue : string;
   floatValue  : float;
 
 {
   // Set up the source string containing a number representation
   stringValue = '123,456';
   // Convert it to a floating point number
   floatValue  = StrToFloat(stringValue);
   // And display the value
   ShowMessage(stringValue+' = '+FloatToStr(floatValue));
 }

Output:

See Also