Str function

Official Content
This documentation is valid for:

To convert a numeric expression into a string.


Str( n1 [ , n2 [ , n3 ] ] )

Type Returned

Is the numeric expression to be converted into a string.

Numeric expression. It is the total length of n1, including numeric sign and decimal point.
Numeric expression. It is the number of decimal places


Returns a character string, aligned to the right, which represents n1 in string format. If you specify fewer decimal places than those in the numeric expression n1, the value is rounded. 

0 <= n2 <= 18

In Visual FoxPro the limit for n3 is: 18 minus one place for the sign, and minus the decimal places. In other words, a limit of 18 places for the whole numeric expression.

In COBOL the limit for n3 is 2.


Insignificant zeros are truncated.

10 = Default value for n2
0 = Default value for n3


Str(1.25) = " 1" 

Note the blank spaces due to the right alignment.

Str(-1.25,10,2) = " -1.25" 

Note the blank spaces due to the right alignment.

Str(-1.25,2,1) = "-1"
Str(-1.25,5,1) = " -1.3"

Note the blank space due to the right alignment.

Str(-1.25,5,2) = "-1.25"
Str(12345678901234.12,13,2) = "*************"
Str(1234.4,5,1) = " 1234" 

Here 1234.4 is rounded and the decimal is discarded because it ends up having a zero value.


Objects    Procedure object, Transaction object, Web Panel object

See also

Concat function
Substr Function
Val function