Convert a Number to a String With Str$()

The Str$ function converts a number to a string.

The (optional) second parameter specifies the length of the string. However, if this number is too large for this format, the resulting string may be longer than you want. If the number is too small, the result will be padded with spaces, according to the sign, on the right (negative) or the left (positive).

The (optional) third parameter specifies the number of decimal places. If it is positive, the number is shown as a floating point number or in scientific notation if it is negative. If the third parameter is not specified, the number of decimal places is set to 0 with integers and, for reasons of compatibility, to 5 with floating decimal values.

 

Examples:

Str$ (Constant.Pi())                Result: "3.14159"

Str$ (Constant.Pi(),0,3)          Result: "3.141"

Str$ (Constant.Pi(),6,3) Result: " 3.141"

Str$ (-Constant.Pi(),12,-3)      Result: "-3.141e+00"

 

To enter the expressions, proceed as follows:

1.  Locate the function in the alphabetical list or filter the functions by entering Str$ in the filter field above the list.

2.  Double-click the "Str$ ()" function to add it to the editing line. This also adds placeholders for the parameters that are expected or accepted by the function. The first of these parameters is selected automatically and you will be prompted to replace this placeholder with a valid value. It's a good idea to first replace all the function's parameters with the respective values before you go on to define the expression.

Functions are also accepted as values for most parameters. The Designer takes care of the correct syntax provided that you also use the "Functions" tab for entering them.

3.  The "Constant.Pi()" function was inserted here as a parameter {number}.

4.  To insert a variable and a function at the same time, use the mouse to drag the variable that you want to the relevant function folder (e.g. "Numerical functions"). The folder opens up automatically and you can select the function that you want with the mouse. If you move the mouse upwards or downwards, the list scrolls automatically in the corresponding direction. If you "drop" the variable onto a function, the function will be inserted with the selected variable as the first parameter.