11-21-2012 05:15 AM
Hello everyone,
I need to convert a float into an hexadecimal value to transmit it on a communication bus (I also have to decode the hexa into a float). I need this hexadecimal to respect the IEEE 754 technical standart. I'm trying to do it with the basic functions of Labview but I'm facing some problems. You'll find attached my VI.
If someone has already done such a function or know an easier way to do it, I'll be very grateful.
11-21-2012 05:25 AM - edited 11-21-2012 05:27 AM
Let me Google that for you:
11-21-2012 06:23 AM
I reproduced the exemple of your link and I haven't the same result. Have you tried it yourself?
Then when I look in the Labview help about the function [Mantissa & Exponent], I see the function returns the mantissa and the exponent corresponding to this formula :
value = [Sign] x [Mantissa] x 2^[Exponent]
But when you check in the standard, you see the the real formula is:
value = [sign] x 1,[mantissa] x 2^[Exponent - shift]
So one of the inner question is how to go from the Labview's mantissa to Standard mantissa?
11-21-2012 07:00 AM - edited 11-21-2012 07:01 AM
What's wrong with just using the Type Cast?
11-21-2012 07:09 AM
I haven't the same results than with this:
http://www.binaryconvert.com/result_float.html?decimal=045049049056046054050053
11-21-2012 07:18 AM
That online converter is using a Single. The default type in LabVIEW for a float is a Double. Change your representation and it works just fine.
11-21-2012 08:00 AM
Ok I've found:
Using only a single as you suggest Crossruls works
But all my previous VI use Doubles, so I cast my Double in Single and then it didn't work any more. So I have to change all my Double into Single.
Thank you!!
11-21-2012 08:23 AM
Or you can use the Double conversion from the same site you gave me earlier:
http://www.binaryconvert.com/result_double.html?decimal=045049049056046054050053
11-21-2012 08:31 AM
Yes that's how I understood my problem : by checking the double conversion on this website.
But I have to use the singles, because the communication bus I interface with works like that.
11-21-2012 08:40 AM - edited 11-21-2012 08:41 AM
If your communication bus in only using singles, then avoid doubles in your code.
How are you converting to a Single from the Doubles? In my quick experiment, I got the right answer.