Converting Real To Float - Siemens SIMATIC IOT Operating Instructions Manual

Hide thumbs Also See for SIMATIC IOT:
Table of Contents

Advertisement

Maintaining and repairing the device
6.6 Configure IOT2050 SM
6.6.2.3

Converting real to float

If the raw value of the module contains real type, convert these values to a float data type.
The following examples show converting real to float with C and Python.
Example: converts real to float with C
/**
* @brief Convert IEEE754 floating point.
*/
double real_to_float(uint32_t real)
{
power_count);
84
printf("Test failed: dq0 != di0\r\n");
break;
}
printf("Test ok\r\n");
}
close(dq0);
close(di0);
return ret;
}
int sign = real >> 31;
int exponent = ((real >> 23) & 0xFF) - 127;
uint32_t mantissa = real & 0x7FFFFF;
int power_count = -1;
double mantissa_int = 0;
for (int i = 0; i < 23; i++) {
mantissa_int += ((mantissa >> (22 - i)) & 1) * pow(2,
Operating Instructions, 03/2024, A5E39456816-AF
SIMATIC IOT2050

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic iot2050Simatic iot2050 smSimatic iot2050 m.2

Table of Contents