Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Real variable into String

How can I convert a real declared variable into a string variable? Is there any function like IntToStr()? RealToStr() function won't work.

like image 979
Tony Avatar asked Dec 19 '25 23:12

Tony


2 Answers

There is a bunch of conversion routines in SysUtils unit, ie FloatToStr and other FloatTo* functions. Also see the Format function.

like image 166
ain Avatar answered Dec 21 '25 16:12

ain


A really old method uses the 'Str' procedure, which has two parameters: the first is a real or integer, and the second is a string variable, into which the formatted number will be placed.

Examples:

i:= 1;
str (i, a);   // a = '1'
r:= 1.5;
str (r:2, a); // a = '1.50'
like image 29
No'am Newman Avatar answered Dec 21 '25 17:12

No'am Newman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!