# Convert Numeric to String

Converts a numeric value (decimal or hexadecimal) to a string.

The number in [Source Data] is converted to a string in the data format (decimal or hexadecimal) specified in [Source Data Format] and stored in [Destination Data].

##### Block

##### Text

TARGET = toString(EXPRESSION, 10, 0);
1 5 2 3/4

# | Description
1 | [Destination Data] Set the destination where you want to store the converted string.
2 | [Source Data Format] Select one of the following formats: ##### Block [Decimal]: Converts a decimal number to a string. [Hex]: Converts a hexadecimal number to a string. ##### Text '10': Converts a decimal number to a string. '16': Converts a hexadecimal number to a string.
3 | [Zero Suppress] ##### Block Select the check box to suppress displaying zeros at the front of values. Clear the check box to specify the number of [Integer Digits], and to add zeros at the front of values to align with the number of digits.
(Example) [Source Data]: 25, [Integer Digits]: 4
When check box is selected (enabled): | 25
When check box is cleared (disabled): | 0025
##### Text Set '0' to suppress displaying zeros at the front of values. Set a numeric value between '1' and '20' to specify the number of [Integer Digits], and to add zeros at the front of values to align with the number of digits.
(Example) [Source Data]: 25
[Integer Digits]: 0 | 25
[Integer Digits]: 4 | 0025
4 | [Integer Digits] Specify the number of digits in the string to convert. Setting Value Range: 1 - 20 When [Script Mode] is [Block], set this value when the [Zero Suppress] check box is cleared.
5 | [Source Data] Set the source data where the number to convert is stored.

(Example)

##### Block

##### Text

Var3=toString(Var1,10,0);

## Operation Example

Variable in [Source Data] | [Zero Suppress] | [Integer Digits] | Variable in [Destination Data] | Comments
Data Type and Value | Format | Maximum Number of Bytes | Converted string
INT: 100 (0x64) | Decimal | Enable | - | 5 | 100 | -
- | 1 | (none) | A string is not stored because the converted string has exceeded the maximum number of bytes that can be stored. It is judged as fail in the "Operation Result" Operation.
Disable | 4 | 5 | 0100 | "0" is added to align with the number of digits specified in [Integer Digits].
2 | 5 | 100 | Even if the value exceeds the [Integer Digits], sets the converted string.
6 | 5 | (none) | A string is not stored because the converted string has exceeded the maximum number of bytes that can be stored. It is judged as fail in the "Operation Result" Operation.
6 | Use [Variable length] | 000100 | "0" is added to align with the number of digits specified in [Integer Digits].
Hex | Enable | - | 5 | 64 | -
- | 1 | (none) | A string is not stored because the converted string has exceeded the maximum number of bytes that can be stored. It is judged as fail in the "Operation Result" Operation.
Disable | 4 | 5 | 0064 | "0" is added to align with the number of digits specified in [Integer Digits].
6 | Use [Variable length] | 000064 | "0" is added to align with the number of digits specified in [Integer Digits].
INT: -100 (0xFF9C) | Decimal | Enable | - | 5 | -100 | "-" Minus sign is supported.
Disable | 4 | 5 | -0100 | "-" Minus sign is supported.
Hex | Enable | - | 5 | FF9C | -
REAL: 100.00 | Decimal | Enable | - | 5 | 100 | Only integer portion is converted.
Hex | Enable | - | 5 | 64 | Only integer portion is converted.
REAL: 100.678 | Decimal | Enable | - | 5 | 100 | Only integer portion is converted.
BOOL: true | - | - | - | 5 | True | -
BOOL: false | - | - | - | 5 | False | -

Note: Even though you set one of the following date type values as the [Source Data], the value is not converted in date/time format to a string. The value is converted in integer format to a string.

- DATE
- TIME
- TIME_OF_DAY
- DATE_AND_TIME

### (Example) DATE_AND_TIME Variable

Date / Time Format: 8/19/2020 10:19:00 AM

Integer Format ([Source Data Format]: [Dec]): 1597799940

Integer Format ([Source Data Format]: [Hex]): 5F3C7E04