4 dint to 1 real
I am communicationg with 3rd party device and getting 4 double values. but the main issue is that how i will convert it to 1 real value. Plese see this link
https://forum-controlsystems.abb.com/20208820/double-to-IEEE754
Voted best answer
Hi,
try to google for an online IEEE-754 floating point converter that can convert to both 64 bit and 32 bit float and show the result in binary and hexadecimal format. Use it to convert your decimal value, look at the 64 bit result in hexadecimal format. Then convert your four integers into hexadecimal format (e. g. with Windows Calculator in Programmer Mode) and compare with the result from online converter. You will see that byte order in integers should be swapped.
I've created a simple program that demonstrates the whole conversion (4 x dint -> 64 bit float -> 32 bit float -> real). There is no overflow check when converting from double (64 bit) to single precision (32 bit) float.
try to google for an online IEEE-754 floating point converter that can convert to both 64 bit and 32 bit float and show the result in binary and hexadecimal format. Use it to convert your decimal value, look at the 64 bit result in hexadecimal format. Then convert your four integers into hexadecimal format (e. g. with Windows Calculator in Programmer Mode) and compare with the result from online converter. You will see that byte order in integers should be swapped.
I've created a simple program that demonstrates the whole conversion (4 x dint -> 64 bit float -> 32 bit float -> real). There is no overflow check when converting from double (64 bit) to single precision (32 bit) float.
Add new comment