Official Content

Converts a numeric expression into a string.


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


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

Type Returned:


Objects: Procedure, Transaction, Work Panel


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.

Note: 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.

See Also

Concat function
Substr function
Val function

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant