# Convert String to Numeric/Float

Converts a string to an integer (decimal, hexadecimal) or real number.

The string in [Source Data] is converted to a numerical value in the data format specified in [InputFormat] and stored in [Destination Data].

##### Block

##### Text

TARGET = parseInt(EXPRESSION);
1 2 3

# | Description
1 | [Destination Data] Set the destination where you want to store the converted numeric value.
2 | [InputFormat] Select one of the following formats: ##### Block [Decimal]: Converts the string to a decimal number. [Hex]: Converts the string to a hexadecimal number. [Float]: Converts the string to a real number. ##### Text 'parseInt': Converts the string to a decimal number. 'parseHex': Converts the string to a hexadecimal number. 'parseFloat': Converts the string to a real number.
3 | [Source Data] Set the source data where the string to convert is stored.

(Example)

##### Block

##### Text

Var1 = parseInt(Var3);

Characters that can be converted are as follows.

InputFormat | Supported Characters
[Decimal] | [-] and [0 to 9]
[Hex] | [A to F], [a to f], and [0 to 9]
[Float] | [-], [.], and [0 to 9]

## Operation Example

Variable in [Source Data] | [InputFormat] | Variable in [Destination Data] | Comments
String | Data Type | Value to store
AA | Hex | INT | 170 (0xAA) | -
Dec | INT | (none) | Format error. It is judged as fail in the "Operation Result" Operation.
AG | Hex | INT | (none) | Format error. It is judged as fail in the "Operation Result" Operation.
Aa | Hex | INT | 170 (0xAA) | Lowercase letters are also supported.
64 | Dec | INT | 64 | -
Hex | INT | 100 (0x64) | -
65535 | Dec | UINT | 65535 | -
Dec | INT | (none) | The string is not stored because the converted number has exceeded the INT variable's input range. It is judged as successful in the "Operation Result" Operation.
12.345 | Float | REAL | 12.345 | The actual data stored may depend on the values supported by the REAL data type.
-1 | Dec | INT | -1 | -
FFFF | Hex | INT | -32768 (0xFFFF) | -
Hex | UINT | 65535 (0xFFFF) | -
True | - | BOOL | True | “True” is stored only if the string is “True” (exact match only). For everything else, “False” is stored.
False | - | BOOL | False | -
true | - | BOOL | False | “True” is stored only if the string is “True” (exact match only). For everything else, “False” is stored.
abc | - | BOOL | False | “True” is stored only if the string is “True” (exact match only). For everything else, “False” is stored.