Cast two integer into one float

Sometime there are 32Bit Float Values stored in 2 16bit Modbus Register.

To work with those two register some byte jougling is needed:

We are assuming that in Register 0x0002 are the MSB and in 0x0001 are the LSB. Therfore we need to shift the Register 2 16bit to the right and perform an Bitwise-“or” on the ofter Register 3. Afterthat we need to copy this integer value into a memory resoure and retrieve it as a float again.

This is necessary as the type casting in sdk arena is not working bitwise.

Please make sure to have the correct length of the mattise and the correct exponent length, to get a valid convertion.

// We assume we are getting the first 12 Register of a Modbus Slave
payload=nb_modbus_read_input_regs(sock, 0,12);
tempint = payload[2] << 16 | payload[3];