2-275
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Data Type Conversion Instructions
2
STRING_TO_** (Text String-to-Real Number Conversion Group)
Example 1: The following example uses the sign, decimal point, and fractional part, but does not
use an exponent.
Example 2: The following example uses the sign, decimal point, fractional part, and exponent.
Name Format
Sign • Any consecutive blank characters at the beginning of the text string are ignored. Any follow-
ing single plus or minus sign is treated as the sign.
• The plus sign can be omitted.
• Any consecutive blank characters after the sign are ignored.
Integer part • The characters after the sign and up to the decimal point are taken as the integer part. Any
consecutive blank characters after the sign are not included in the integer part. The sign may
sometimes be omitted.
• If the decimal point and fractional part are omitted, the characters up to the exponent are
taken as the integer part.
• If the decimal point, fractional part, and exponent are omitted, the characters up to the end
of the text string are taken as the integer part.
• The integer part consists of ‘0’ to ‘9’.
• The integer part cannot be omitted.
• The maximum number of digits in the integer part is the maximum text string length of 1985
minus the total number of bytes in the following: the sign, decimal point, fractional part, expo-
nent, and blank characters before and after the sign.
Decimal
point
• A single period (‘.’) following the integer part is taken as the decimal point.
• Omit the decimal point if there is no fractional part.
Fractional
part
• The characters after the decimal point and up to the exponent are taken as the fractional
part.
• If the exponent is omitted, the characters up to the end of the text string are taken as the
fractional part.
• The fractional part consists of ‘0’ to ‘9’.
• The fractional part can be omitted.
• The fractional part can consist of a maximum of 15 digits.
• If there is no decimal point, then there is no fractional part.
Exponent • The exponent consists of a single ‘e’ or ‘E’ after the fractional part, a following single plus or
minus sign, and the remaining characters to the end of the text string.
• If there is no fractional part, then the above text string after the decimal point is taken as the
exponent.
• If there is no decimal point or fractional part, then the above text string after the integer part
is taken as the exponent.
• The numeric part of the exponent consists of ‘0’ to ‘9’.
• The exponent can be omitted.
• The numeric part of the exponent can consist of a maximum of three digits.
abc:=STRING_TO_LREAL(‘-123.4567’);
LD ST
abc
‘-123.4567’
STRING_TO_LREAL
EN ENO
In
STRING data
LREAL data
-1.234567e+2
In Out=abc
- 1 2 3 . 4 5 6 7
‘ ’
STRING data LREAL data
1.234567e+4
In Out=abc
+ 1 2 3 . 4 5 6 7 e + 0 2
‘ ’