Purpose |
Return the
|
Syntax |
s$ = STR$(numeric_expression [, digits]) |
Remarks |
STR$ returns the string form of a
For example, STR$(14) returns a three-character string, of which the first character is a space, and the second and third are the ASCII characters "1" and "4". LTRIM$ can be used to remove leading space characters. digits specifies the maximum number of significant digits (1 to 18) desired in the result. STR$ can also be used to convert numeric values with more than 16 significant digits (i.e., Extended-precision floating-point and Quad-integers) to a printable form. For example: a## = 2.0/3.0 x$ = STR$(a##,18) returns 0.666666666666666667. The complementary function is VAL, which takes a string argument and returns the numeric equivalent. Thus, number = VAL(STR$(number)). An integer-class numeric value may also be converted to a string with the FORMAT$ and USING$ functions; however, FORMAT$ can easily return a string that is free from leading space characters. For example, x$ = FORMAT$(a&). |
See also |
|
Example |
x$ = STR$(-1,5) x$ = STR$(5/3,2) x$ = STR$(5/3,8) x$ = STR$(100000## / 3##, 18) |
Result |
-1 1.7 1.6666667 33333.3333333333333 |