|
Description It is not possible to directly process a 64-bit data type in a SIMATIC S7-300/400 CPU. You must therefore convert it into a different data type for processing. Such a conversion can lead to loss of precision and/or limitation of the value range. These restrictions are caused on the one hand by the reduced data type width of 32 bits and on the other hand by the representation of the approximation of all floating-point formats.
Note
Information about the configuration and the value range of a 64-bit data type (LREAL) is available in the Online Help of STEP 7.
The STEP 7 library attached in this entry for downloading has four functions. These are for converting a 64-bit floating-point number (according to standard IEEE 754) into the data types below
- DINT (32-bit integer) for integer values (FC2)
- REAL (32-bit floating point) for broken rational numbers (FC3)
and for converting to a 64-bit floating-point number from the data types below
- DINT (32-bit integer) for integer values (FC1)
- REAL (32-bit floating point) for broken rational numbers (FC4)

Fig. 1: Configuration of the STEP 7 program from the attached library
The table below lists the interface parameters of the functions.
| Name |
Type |
Description |
| DINT2LREAL (FC1) |
| IN |
Input |
Input of the number value of the DINT data type |
| OUT |
Output |
Output of the number value of the LREAL data type |
| LREAL2DINT (FC2) |
| IN |
Input |
Input of the number value of the LREAL data type |
| Ret_Val |
Return |
Output of the number value of the DINT data type |
| STATUS |
Output |
Output of the status value* |
| LREAL2REAL (FC3) |
| IN |
Input |
Input of the number value of the LREAL data type |
| Ret_Val |
Return |
Output of the number value of the REAL data type |
| STATUS |
Output |
Output of the status value* |
| REAL2LREAL (FC4) |
| IN |
Input |
Input of the number value of the REAL data type |
| OUT |
Output |
Output of the number value of the LREAL data type |
Table 1
* The status information is constructed bit for bit. Table 2 lists the descriptions of the separate bits.
| Bit no. |
Description |
| 0 |
LREAL value is greater than zero |
| 1 |
LREAL value is less than zero |
| 2 |
Input value is less than zero |
| 3 |
Input value is greater than zero |
| 4 |
Loss of information upon conversion |
| 5 |
Reserved |
| 6 |
Warning |
| 7 |
Error |
Table 2
The STEP 7 library attached for downloading also contains a monitoring table. You can use this table to give values to the functions.

Fig. 2: Excerpt from the monitoring table
Download
64_bit_conversion.zip ( 462 KB )
Creation environment The download in FAQ entry was created with the Totally Integrated Automation Portal V11 SP1.
|