STR$ (x#, w) where x# is a floating point number |
Purpose | Convert the floating-point variable x# into a string representation with w
number of characters, where either 8 < w < 14 or -6 < w < 0 This function shares the same function name as the STR$(n, d) found in TL6, where n is the integer value and d is the number of characters. When n is an integer STR$(n, d) will return the string exactly as described in TL6 programmer's Reference to maintain backward compatibility. However, when the first operand is a float, the function STR$(x#, w) will only return the string according to the following rules:
a) When w is zero, STR$(x#, 0) returns a string representing an integer equal to rounding of x# to the nearest integer. b) When w < 0, the function will never return a string in scientific notation, but will always return x# as a regular expression nnn.ffff where |w| represents the number of decimal places. E.g. STR$(0.0123456, -4) => 0.0123 (4 decimal places) c) When w is a positive number, STR$(x#, w) function will only return a string representation of x# in scientific notation in the following format: + d.fffffffE+nn The shortest format that this function returns is: +d.fE+nn which is is 8 characters wide. The longest format that this function returns is +d.fffffffE+nn which is 14 characters wide |
||||||||||
Example | A$ = STR$(0.000012346, 10) B$ = STR$(-0.000012346,8) C$ = STR$(-0.000012346,16) D$ = STR$(-0.000012346,12) Result : A$ = "+1.235E-05" B$ = "-1.2E-05" C$ = "-1.2346000E-05" D$ = "-1.23460E-05" |
||||||||||
Comments | If w is < 8 but > 0, the function will return the shortest form
which is 8 characters wide. If w > 14 the function will return the longest form which
is 14 characters wide. The data will be rounded up to the precision level necessary to represent the data in w number of characters. |