STR
STR converts a floating point number to a string representing the value in decimal notation.
The number passed to the STR function must use .
(period) as the decimal separator and
,
(comma) as the thousand separator. Any other decimal or thousand separators will cause
incorrect results.
This function is valid in both TM1® rules and TurboIntegrator processes.
Syntax
STR(number, length, decimal)
Argument |
Description |
---|---|
number |
The floating point number being converted to a string. This number can contain a positive or negative sign. This number can contain decimal places. |
length |
The desired count of characters in the string representation, including sign,
separators, decimal, or decimal places. The length argument value should be a
positive number greater than If the count of digits in the number is less than the length argument value, the function inserts leading blank spaces to attain this length after inserting sign, separators, decimal, or decimal places. If the
count of digits in the whole number exceeds the length argument value
and the decimal argument value is If the count of digits in the number exceeds the
length argument value and the decimal argument
value is greater than |
decimal |
The number of decimal places to include in the function result. If this parameter is If the number specified has more decimal places than the decimal argument, the function result is rounded. |
All arguments are required and you cannot pass empty argument values.
Examples
Function call | Number | Length | Decimal | Result |
---|---|---|---|---|
STR(3.14159, 6, 2) | 3.14159 | 6 | 2 | 3.14 |
STR(-3.14159, 6, 0) | -3.14159 | 6 | 0 | -3 |
STR(3.14159, 5, 3) | 3.14159 | 5 | 3 | 3.142 |
STR(1000000, 4, 0) | 1000000 | 4 | 0 | 1000 Note that the number is truncated. |
STR(1000000, 4, 2) | 1000000 | 4 | 2 | 1000000.00 Note that the number is not truncated because decimal is specified. |
STR(10, 2, 4) | 10 | 2 | 4 | 10.0000 |
STR(120536.74391, 8, 0) | 120536.74391 | 8 | 0 | 120536 The result includes left padding of two spaces to attain the specified length of 8. |
STR(120536.74391, 5, 0) | 120536.74391 | 5 | 5 | 12053 The count of digits in the whole number exceeds the
length argument value and the decimal argument
value is |