SmartPascal
Str
Procedure
Converts an integer or floating point number to a string System unit
 procedure Str ( const Number { : const Width {; var TargetString ) ;
Description
The Str procedure converts an integer or floating point Number into a string, with optional basic formatting control.
 
By default, floating point numbers are shown in Exponential format, as here:
 
1.23400000000000E+0001
 
Specifying a Width guarantees that the output string will be at least that wide, with left blank padding added as appropriate.
 
When you specify Width, you can also specify Decimals for floating point numbers, which changes the display format to fixed as here:
 
1.234
 
Both Width and Decimals values may be provided by integer constants or variables.
Related commands
Format Rich formatting of numbers and text into a string
IntToStr Convert an integer into a string
StrToInt Convert an integer string into an Integer value
 
Example code : A simple example
var
  intNumber   : Integer;
  floatNumber : Double;
  text        : string;

begin
  // Assign values to our numbers
  intNumber   := 123;
  floatNumber := 987.654;

  // Display these numbers using vanilla 'Str'
  Str(intNumber, text);
  ShowMessage('intNumber   = '+text);
  Str(floatNumber, text);
  ShowMessage('floatNumber = '+text);

  // Now display using width and decimal place sizes
  Str(intNumber:10, text);
  ShowMessage('intNumber   = '+text);
  Str(floatNumber:10:4, text);
  ShowMessage('floatNumber = '+text);
end;
Show full unit code
   intNumber   = 123
   floatNumber = 9.87654000000000E+0002
   intNumber   =        123
   floatNumber =   987.6540